Skip to content

OOM crashes still possible for GIFs with a high number of required frames #24835

@mklim

Description

@mklim

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

  1. Find a large GIF with a high amount of required frames (example posted in this comment).
  2. 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());
}
  1. flutter run on 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 consoleengineflutter/engine related. See also e: labels.platform-iosiOS applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions