Skip to content

svg icons are not rendered correctly #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BigGitWorld opened this issue Jul 1, 2022 · 14 comments
Open

svg icons are not rendered correctly #255

BigGitWorld opened this issue Jul 1, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@BigGitWorld
Copy link

BigGitWorld commented Jul 1, 2022

Hi.
I was using flutter-pi corresponding to flutter 2.8 and everything was working fine in both my laptop (ubuntu) and raspberrypi.
I upgraded my flutter to the version 3.0.3 and also updated flutter-pi and engine-binaries, but I don't know why my SVG icons are not shown correctly sometimes in the raspberrypi (I tested it both debug and release mode), while everything is working fine in my laptop (ubuntu).

The following images are 2 cases from raspberrypi :

bad rendered images:
IMG_20220701_225157

correct images:
IMG_20220701_225207

what is the problem?

@ardera
Copy link
Owner

ardera commented Jul 1, 2022

what method are you using for rendering the svg images? which package are you using? or is there some way to render svgs with vanilla flutter?

@BigGitWorld
Copy link
Author

BigGitWorld commented Jul 2, 2022

I'm using latest version of flutter_svg package.

example:

import 'package:flutter_svg/flutter_svg.dart';

SizedBox(
    width: 100,
    height: 100,
    child: SvgPicture.asset( 'assets/icons/temperature.svg',  color: Colors.white,),
),

I'm using this package for different projects and its working fine in android/iOS, web.
Also as I mentioned, Its working with flutter-pi corresponding to the flutter 2.8.

@ardera
Copy link
Owner

ardera commented Jul 2, 2022

Can you send me some example svgs that don't work for you?

@BigGitWorld
Copy link
Author

BigGitWorld commented Jul 3, 2022

sure. I emailed you ([email protected]) some pictures.

@ardera
Copy link
Owner

ardera commented Jul 3, 2022

Somehow these all work fine for me:

VID_20220703_180713.mp4

(EDIT: different link: https://photos.app.goo.gl/giPr8Gwc9czB5uTq6)

This is with latest flutter-pi and flutter 3.0.3. (I used the SizedBox template you commented)

It could be a weird Heisenbug maybe some race condition with rendering. You can try fiddling with the rendering a bit, maybe add an invisible overlay layer or something. (That helped in the past)

Other than that you can also try reducing the pages of your app where the problem ocurrs to some minimal code that reproduces the issue. I don't know if this is a graphics driver, flutter, flutter_svg or flutter-pi bug and I'd like to look into it, but I can't do anything when I can't reproduce it

@BigGitWorld
Copy link
Author

Thank you so much dear @ardera.
When I used png images instead of svg, everything works fine. So I think something is wrong with svg.

It could be a weird Heisenbug maybe some race condition with rendering. You can try fiddling with the rendering a bit, maybe add an invisible overlay layer or something. (That helped in the past)

can you provide an example please?

Other than that you can also try reducing the pages of your app where the problem ocurrs to some minimal code that reproduces the issue. I don't know if this is a graphics driver, flutter, flutter_svg or flutter-pi bug and I'd like to look into it, but I can't do anything when I can't reproduce it

The pages that this problem occurs, are not heavy. first I'm getting data from database or shared_preferences and then give the values to the UI and everything was working fine with flutter-pi corresponding to the flutter 2.8.

@dLogicC
Copy link

dLogicC commented Jul 5, 2022

Hi,
I have the same problem, and I haven't been able to find the cause yet. Only svg, with png everything works fine.
In my case it is quite random, in the sense that if I change the page and then return to the previous one it may be that it is displayed correctly, but also the reverse, that is, it was first displayed correctly and then badly.

@ardera Thanks for this fantastic project!

@BigGitWorld
Copy link
Author

@dLogicC
which version of flutter are you using?

@dLogicC
Copy link

dLogicC commented Jul 6, 2022

@dLogicC
which version of flutter are you using?

3.0.3, but also in version 3.0.0 there was the same problem.

@ardera
Copy link
Owner

ardera commented Jul 6, 2022

@BigGitWorld

can you provide an example please?

Opacity(opacity: 0.9999, child: ...);
DecoratedBox(
  position: DecorationPosition.foreground,
  decoration: BoxDecoration(
    color: const Color(0x01000000),
  ),
  child: ...
);
Stack(children: [..., Positioned.fill(child: ColoredBox(color: Colors.transparent)]);
RepaintBoundary(child: ...);

something like that

@BigGitWorld
Copy link
Author

@ardera
Thank. But unfortunately your above solution did not help and SVG pictures are not rendered successfully yet.

@gerkol
Copy link

gerkol commented Aug 2, 2022

Hi @BigGitWorld I had the same problem. For me the solution was to add some missing libraries to my image. Specifically I followed the instructions in: https://github.com/jwinarske/manifests/tree/honister for the DRM version. Make sure to rename flutter-pi to flutter-pi-release though. Otherwise you will get "Nothing provides flutter-pi" from bitbake. Hope this will help you.

@ardera
Copy link
Owner

ardera commented Nov 1, 2022

It could be this is caused by flutter enabling usage of stencil buffers in 3.0: https://github.com/flutter/engine/blob/d1b9a6938ad77326ac3a94d92bbc77933ed829ed/shell/platform/embedder/embedder.cc#L624

They were disabled in 3.3 again though, so if that's the cause the rendering artifacts should be gone in 3.3.

@ardera
Copy link
Owner

ardera commented Nov 1, 2022

I'll add EGL_STENCIL_SIZE, 8 to the context options, that should fix it should they decide to enable stencil buffer usage again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants