Skip to content
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

Fetching gifs crashs on iPhone 10 and iPad 6 - Out of memory #9

Open
SchillingSebastian opened this issue Sep 28, 2023 · 0 comments
Open

Comments

@SchillingSebastian
Copy link

Hey there 👋

The last couple days I was debugging our application for out-of-memory failures on iPhone 10 and iPad 6 (both using iOS 15 or iPad OS 16).
We got messages like this:

* thread #12, name = 'io.flutter.1.io', stop reason = EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=1450 MB)
    frame #0: 0x000000022e02483c AGXMetalA10`___lldb_unnamed_symbol2784 + 632
AGXMetalA10`___lldb_unnamed_symbol2784:
->  0x22e02483c <+632>: st1.4s { v16, v17, v18, v19 }, [x4]
    0x22e024840 <+636>: add    x4, x4, #0x80
    0x22e024844 <+640>: st1.4s { v20, v21, v22, v23 }, [x4]
    0x22e024848 <+644>: add    x4, x4, #0x80

While this might be a common issue on pages which have lots of pictures which are not cached correctly, we eliminated such issues first. We also suspected other kind of problematic async code parts to be at fault, but what was bugging me is that we suddenly overshoot in memory by GB not MB. This was not really visible in the memory debug view and its pain to find out whats going wrong.
On newer devices e.g. iPhone 11 there were no crashes. The same holds true for the emulated devices. Only a real iPhone 10 or an iPad 6 was crashing.

To reproduce please use this flutter application:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_gif/flutter_gif.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  Future<void> doFetching() async {
    await fetchGif(const AssetImage('assets/images/this_is_fine.gif'));
  }

  @override
  Widget build(BuildContext context) {
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      unawaited(doFetching());
    });
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello World!'),
        ),
      ),
    );
  }
}
name: flutter_gif_oom
description: A new Flutter project.
publish_to: 'none'
version: 0.1.0

environment:
  sdk: '>=3.1.2 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_gif: 0.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

  assets:
      - assets/images/my_gif.gif

It seems to be related to gif loaded. It crashes for a 1.8mb gif but doesn't e.g. for a 94mb gif.
I'll ask for permission to upload the gif here as well. If I receive it, then I'll upload it to this issue.

Maybe it is also not wise to use an unmaintained <0.1.0 library for anything else than testing 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant