Repository navigation
Closed
Labels
c: crashStack traces logged to the consoleStack traces logged to the consoleengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-iosiOS applications specificallyiOS applications specificallywaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
The limit added to cached decoded GIF frames in #20998 doesn't apply to required frames.
More info on required and dependent frames is covered in this article on caching decoding frames in Chromium.
Steps to Reproduce
- Find a large GIF with a high amount of required frames (example posted in this comment).
- Add it to the following app.
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());
}flutter runon an iOS 10.3.3 device
Expected: GIF animates.
Actual: App crashes.
Logs
[ +8 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0x17d3b87c, isolate: {type: @Isolate, fixedId: true, id: isolates/611148326, name: main.dart$main.dart-611148326, number: 611148326}}]}
[ ] Connected to _flutterView/0x17d3b87c.
[ +1 ms] 🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[ ] An Observatory debugger and profiler is available at: http://127.0.0.1:1033/
[ ] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
[+44623 ms] Service protocol connection closed.
[ +1 ms] Lost connection to device.
[ ] Sending to VM service: _deleteDevFS({fsName: tester})
[ +254 ms] TimeoutException after 0:00:00.250000: Future not completed
[ +4 ms] "flutter run" took 83,168ms.
Analyzing tester...
No issues found! (ran in 1.7s)
[✓] Flutter (Channel master, v0.11.8-pre.40, on Mac OS X 10.13.6 17G2112, locale en-US)
• Flutter version 0.11.8-pre.40
• Framework revision 9d878ca493 (17 hours ago), 2018-11-27 22:31:49 -0800
• Engine revision be973ea196
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consoleengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-iosiOS applications specificallyiOS applications specificallywaiting for PR to land (fixed)A fix is in flightA fix is in flight
Activity
tsun424 commentedon Nov 29, 2018
Hi @mklim , following the issue #20998 , the only doubt I have is I've tested the same gif file on several devices, including 2 iPads, iPad mini, iPhone and Android phone, the crash only happened on 1 iPad and iPad mini, for other iPad, iPhone and Android, no any crash observed.
mklim commentedon Nov 29, 2018
@tsun424 double checked to make sure and I'm seeing the test GIF interpreted the same way across multiple different OS versions. Looks like there's always a linear climb in memory usage based on every frame being required until the GIF fully animates once (800MB) or the OS shuts the app down for using too much memory. It's hard to say for sure why we're only seeing actual crashes in that specific OS version, but my guess is that it happens to be more aggressive about shutting down the app for using memory like this than the other OS versions are. Or there's some strange coincidence where the 10.3.3 devices are all more memory constrained. I think larger GIFs with all required frames would probably go on to trigger crashes in other combinations of OS versions/devices too.
tsun424 commentedon Nov 29, 2018
Hi @mklim , make sense, appreciate your further checks. 👍
eseidelGoogle commentedon Nov 30, 2018
I wonder what Chrome's gif decoder/playback does. I know the person who used to maintain that code, but we'd have to do digging to find out the modern maintainer if that's helpful to you.
mklim commentedon Nov 30, 2018
@eseidel Thanks! If I'm remembering right, they generally cache the previous frame to avoid repetitive decodes for cases of required frames like this, and then never try to cache non-required frames to avoid decoding again on loop. So they're using much less memory than us at the expense of CPU/battery. I think that makes sense in a lot of cases, but earlier when I was solving the original bug it sounded like we didn't want to unilaterally make the same tradeoff. Maybe we want to expose that kind of behavior as a lever or something going forward though? /cc @Hixie
Hixie commentedon Nov 30, 2018
Using 800MB for one GIF is clearly beyond reasonable, but I've no idea what the right heuristic is.
Only overflow the cache for one required frame (#7048)
github-actions commentedon Aug 31, 2021
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
flutter doctor -vand a minimal reproduction of the issue.Only overflow the cache for one required frame (flutter-team-archive/…