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
Animated gif is causing my App to crash on some Android devices and iOS 12. Seems fine on iOS 11 and below. #20998
Comments
Can you provide any error output? Perhaps using |
When I do flutter run this is what I get right before it crashes. The animated gif is on my first screen:
|
same thing with flutter logs |
When I comment out the Image with the animated gif. Does not crash. |
Can you make the image available or can you try if you can reproduce with an available image? |
how can I get the file to you, it is 24 MB |
It is crashing on iOS 11 as well. I ran the Flutter app on my Wife's phone last night. |
24MB shouldn't be an issue. Can you upload here or do you rather not have it public? |
I would rather not have it public, eventually when my app is released I will release it public for fun. But I tried uploading here and it says 24 mb is too big. |
I see. If I have the image I can try to reproduce it here, but that won't buy us much, you already reproduce on different devices. The people working on fixing the bug are at the other side of the planet ;-) |
ok, thanks |
When do you think they will be interested into looking into this? We are planning on releasing in less than a month and will have to just rip out the animated gifs if we can't get this looked at. |
I don't know about that. There is a lot in the pipeline. |
Hi @mjaffa-figure, would you mind pulling the crash reports and pasting them here? Open Xcode with the device attached on which you had the crash, then go to Window > Devices and Simulators, select your device and pick the crash report, which should include the stack trace and other info. |
/cc @amirh |
This is the iOS 12 log on an iPhone X. Let me know if you need an iOS 11 with iPhone 8, I can capture that as well. Let me know if you need the animated gif sent to you. It is 24 MB like I mention above so we would need to find another way to send to you.
Here is the crash log. |
It will be great if you could share the file, maybe through Google Drive? |
Ok will do: new Container(constraints: BoxConstraints.tightFor(
width: width, height: width),
child: new Image(
image: new AssetImage("assets/poo.gif"))) Here is the google Drive link: |
I haven't reproduced a crash on initial load, but I am consistently seeing Jetsam terminating the app after 5 or seconds of the gif running. Test patch here, on In the crash report included earlier in the issue it looks like the process was terminated by iOS itself ( |
Still getting crash in:
|
Oh sorry, I was asked by @zoechi to test another issue on this build, not this issue, but yeah this one still no working. 😢 |
Will keep you posted @mjaffa-figure. You may want to keep an eye out for flutter/engine#6310. That should fix this problem in most cases. It's likely to go in first even though it's newer. flutter/engine#6230 is a broader fix but its behavior is surprising and conditional, so it's not going to be merged in as the primary way of handling this. |
Users can set `PaintingBinding.decodedCacheRatioCap` to control the max amount of memory used per image to avoid decoding frames each animation loop. This depends on flutter/engine#6310. Fixes #20998, and fixes #14344
@mklim , I just upgraded to the latest beta of flutter, but crash still happens on iPad, do I need to change anything from my code? Thanks.
|
@tsun424 thanks for the report. Ideally this should be fixed without anything else required. But one problem I can think of is that the fix doesn't address problems caused by loading multiple gifs at once. You should be able to disable all caching and fix crashers from this in your app by setting the decoded cache ratio to |
Hi @mklim , thanks for your response. I just did another test, tried to set class _ThirdSlideState extends State<ThirdSlide> {
@override
void initState() {
PaintingBinding.instance.decodedCacheRatioCap = 1.0;
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: Theme.of(context).primaryColor),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(
child: Image(
image: AssetImage("assets/welcome1.gif"),
fit: BoxFit.cover,
),
),
]),
);
}
} From my testing, this crash only happens when it's a large gif file, small gif works fine, and the large gif can be playing, just crash suddenly. iPad Specs: I tested this from iPad(iOS 10.3.3) and iPad mini(iOS 10.3.3) |
Hey @tsun424, thanks for the extra info and for your patience. That code does look right to me. If |
Hi @mklim , I've created a simple app(using code snippet in my last comment) for testing and done several tests on different iPads/Android devices, following is what I've observed, my testing gif file is 16MB, which is over the max image limitation(10MB) of github, couldn't upload here, I can upload somewhere else if you want to use it to test, but from my testing, I guess this issue is related with iOS versions, see below testing result:
Result: crash only happened on specific iOS version, it's iOS 10.3.3 from my testing, and crash happened at the same time(after 53 seconds playing). I am sure you can reproduce it if you have such version(iOS 10.3.3) of iOS device. Please let me know if you need any further information. Thanks. |
@tsun424 thanks again for the extra info. I still haven't been able to reproduce this unfortunately. It's just an educated guess, but I think the problem you're seeing may be that the image you're using has a bunch of "required" frames. We still always cache those, so that's one way I can think of where you would still be seeing this with a single image. I'd like to see your file to confirm for sure that that's the issue you're seeing though. Could you possibly upload the GIF to another file hosting service besides Github and link it here? Here's the full import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class ThirdSlide extends StatefulWidget {
@override
_ThirdSlideState createState() => _ThirdSlideState();
}
class _ThirdSlideState extends State<ThirdSlide> {
@override
void initState() {
PaintingBinding.instance.decodedCacheRatioCap = 1;
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: Theme.of(context).primaryColor),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(
child: Image(
image: AssetImage("assets/test.gif"),
fit: BoxFit.cover,
),
),
]),
);
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => Container(child: ThirdSlide());
} I've experimented with a few different cache settings, here's the behavior I'm seeing on 10.3.3:
One thing worth noting is that I haven't been able to get a 10.3.3 iPad specifically to test with so far, my 10.3.3 device is an iPhone. There could also be something about 10.3.3 iPads that causes this to happen, but I'm thinking the required frames issue is more likely. |
Hi, @mklim , I've uploaded the gif file to google drive, you can download it from below link and see if you can reproduce the issue. For gif files, I've tested 3 different gif files(they are all converted from mp4 files to gif by a same tool, maybe that's the issue) on those devices, they all had similar crash issue. |
Thanks @tsun424! That's enough for me to debug the issue. I filed #24835 to track this. From what I can tell every single frame in With any luck there may be a setting in the tool you're using to encode with more independent frames, or you may be able to find and use a different tool that encodes the files differently. I'll work on updating |
Hi @mklim , cheers! 🍺 Thanks for your analysis and suggestion, I'll try the workaround solution and keep an eye on the new issue you created. |
@cbracken #6500 is open for providing better stack traces when we run out of memory. As far as I can tell it's blocked on #22818, adding handling for engine crashes in general. I think that's probably the most robust way of making crashes like this less opaque, but adding it in is going to be complex. It may be worth adding a page to the Wiki on potential memory issues around images, or memory issues in general? We could also mention in the framework headers that animated images are expensive to render so to be careful with adding large files. Neither of those would really be obvious in the case of a crash though. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
The animated gif is about 10 MB
The text was updated successfully, but these errors were encountered: