Skip to content

Flutter crashed because of OOM #28037

Closed
Closed

Description

@mjaffa-figure

Steps to Reproduce

switch to flutter channel master
or flutter channel dev

flutter version on master as of this bug 1.2.2
flutter version on dev is 1.2.1

Run your flutter application on iPhone 5s.

It will crash a little bit into using your application.

If you switch to flutter channel beta it will work on iPhone 5s
flutter version on beta channel = 1.1.8



Working channel flutter doctor output:

flutter doctor -v
[✓] Flutter (Channel beta, v1.1.8, on Mac OS X 10.14.3 18D109, locale en-US)
    • Flutter version 1.1.8 at /Users/matthewjaffa/flutter
    • Framework revision 985ccb6d14 (5 weeks ago), 2019-01-08 13:45:55 -0800
    • Engine revision 7112b72cc2
    • Dart version 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/matthewjaffa/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.3
    • Dart plugin version 182.5124
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] VS Code (version 1.31.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • iPhone 5s • F2C2A7C0-F52B-4CBC-9EF6-A4B9A2D96FEF • ios • iOS 12.1 (simulator)
    • iPhone SE • 5171C5DD-E530-45FA-A071-57128E6A631D • ios • iOS 12.1 (simulator)
    • iPhone XS • E5A5E876-8F77-4C25-A9D0-668C77E2F0DD • ios • iOS 12.1 (simulator)

! Doctor found issues in 2 categories.


Failing flutter doctor version output:

flutter doctor -v
[✓] Flutter (Channel dev, v1.2.1, on Mac OS X 10.14.3 18D109, locale en-US)
    • Flutter version 1.2.1 at /Users/matthewjaffa/flutter
    • Framework revision 8661d8aecd (26 hours ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/matthewjaffa/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.3
    • Dart plugin version 182.5124
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] VS Code (version 1.31.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • iPhone 5s • F2C2A7C0-F52B-4CBC-9EF6-A4B9A2D96FEF • ios • iOS 12.1 (simulator)
    • iPhone SE • 5171C5DD-E530-45FA-A071-57128E6A631D • ios • iOS 12.1 (simulator)
    • iPhone XS • E5A5E876-8F77-4C25-A9D0-668C77E2F0DD • ios • iOS 12.1 (simulator)

! Doctor found issues in 2 categories.

Activity

  1. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 16, 2019
  2. kangwang1988 commented on Feb 16, 2019

    @kangwang1988
    Contributor

    Fail to reproduce this issue using the latest master.

    KyleWongdeMacBook-Pro:flutter_issue_28037 kylewong$ flutter doctor -v
    [✓] Flutter (Channel master, v1.2.2-pre.19, on Mac OS X 10.14.4 18E184e, locale en-CN)
        • Flutter version 1.2.2-pre.19 at /Users/kylewong/Codes/Flutter/alibaba-flutter/flutter
        • Framework revision 20d9de58d0 (7 hours ago), 2019-02-15 18:43:36 -0800
        • Engine revision 033f2072c3
        • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at /Users/kylewong/Library/Android/sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.3
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
        • All Android licenses accepted.
    
    [!] iOS toolchain - develop for iOS devices (Xcode 10.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 10.1, Build version 10B61
        ✗ Verify that all connected devices have been paired with this computer in Xcode.
          If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
          To update with Brew, run:
            brew update
            brew uninstall --ignore-dependencies libimobiledevice
            brew uninstall --ignore-dependencies usbmuxd
            brew install --HEAD usbmuxd
            brew unlink usbmuxd
            brew link usbmuxd
            brew install --HEAD libimobiledevice
            brew install ideviceinstaller
        • ios-deploy 1.9.4
        • CocoaPods version 1.6.0
    
    [✓] Android Studio (version 3.3)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 32.0.1
        • Dart plugin version 182.5215
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    
    [✓] VS Code (version 1.31.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 2.23.0
    
    [✓] Connected device (2 available)
        • MHA AL00  • GWY7N16B02004245                     • android-arm64 • Android 8.0.0 (API 26)
        • iPhone 5s • 7A4246EF-D6EE-44DE-8DA1-2D2E7D32D76B • ios           • iOS 12.1 (simulator)
    
    ! Doctor found issues in 1 category.
    KyleWongdeMacBook-Pro:flutter_issue_28037 kylewong$ flutter run -d  7A4246EF-D6EE-44DE-8DA1-2D2E7D32D76B
    Launching lib/main.dart on iPhone 5s in debug mode...
    Running Xcode build...                                                  
     ├─Assembling Flutter resources...                           1.5s
     └─Compiling, linking and signing...                         2.3s
    Xcode build done.                                            5.4s
    Syncing files to device iPhone 5s...                             1,943ms
    
    🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
    An Observatory debugger and profiler on iPhone 5s is available at: http://127.0.0.1:63513/
    For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".

    screen shot 2019-02-16 at 5 50 51 pm

  3. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author

    Sorry should have put this in the original post. Works just fine in the simulator. But fails on the actual real physical device iPhone 5s. I will try with a simple project like above to be sure it is failing on any flutter project on the actual device.

    @kangwang1988

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 16, 2019
  5. kangwang1988 commented on Feb 16, 2019

    @kangwang1988
    Contributor

    @mjaffa-figure
    Can you paste the fail log?

  6. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author

    @kangwang1988
    This is the fail log:

    [  +13 ms] DevFS sync failed. Lost connection to device: SocketException: Write failed (OS Error: Broken pipe, errno = 32), address = 127.0.0.1, port = 64747
    [        ] Syncing files to device Jenaka’s iPhone... (completed in 7,641ms, longer than expected)
    [   +1 ms] "flutter run" took 101,016ms.
    [        ] "flutter run" took 101,016ms.
    
    #0      throwToolExit (package:flutter_tools/src/base/common.dart:24:3)
    #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:418:7)
    <asynchronous suspension>
    #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:545:18)
    #3      _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
    #4      _rootRunUnary (dart:async/zone.dart:1132:38)
    #5      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #6      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
    #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
    #8      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
    #9      Future._complete (dart:async/future_impl.dart:473:7)
    #10     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
    #11     _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
    #12     _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:294:13)
    #13     RunCommand.usageValues (package:flutter_tools/src/commands/run.dart)
    #14     _asyncThenWrapperHelper.<anonymous closure> (dart:async/runtime/libasync_patch.dart:77:64)
    #15     _rootRunUnary (dart:async/zone.dart:1132:38)
    #16     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #17     _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
    #18     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
    #19     Future._propagateToListeners (dart:async/future_impl.dart:668:32)
    #20     Future._complete (dart:async/future_impl.dart:473:7)
    #21     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
    #22     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async/runtime/libasync_patch.dart:33:20)
    #23     _rootRun (dart:async/zone.dart:1124:13)
    #24     _CustomZone.run (dart:async/zone.dart:1021:19)
    #25     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
    #26     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
    #27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
    #28     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
    #29     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
    
  7. kangwang1988 commented on Feb 16, 2019

    @kangwang1988
    Contributor

    Duple of #16491

  8. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author

    @kangwang1988
    I get that same fail log if I try to run on a device when signing files. Are you sure it is a duplicate of that other issue? This was working just fine on Flutter 1.1.8.

    When I run from Xcode I get this line:

    2019-02-16 08:49:51.935523-0700 Runner[329:11307] Task <031F97C3-7754-4E07-938F-657788D10D4F>.<2> finished with error - code: -1003
    Message from debugger: Terminated due to memory issue
    
  9. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author

    #16491 is a Flutter doctor issue. I have no problem with flutter doctor.

  10. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author

    It is a memory issue. I have this Asset class which pre-loads my assets to be used throughout my game. When I comment out over half them to not be pre-loaded it is not crashing.

    This was working fine with flutter 1.1.8. With flutter 1.2 and above did something change with allowing us to have less assets loaded into memory?

  11. mjaffa-figure commented on Feb 16, 2019

    @mjaffa-figure
    Author
  12. kangwang1988 commented on Feb 16, 2019

    @kangwang1988
    Contributor

    Leave it open as it seems different.

  13. kangwang1988 commented on Feb 16, 2019

    @kangwang1988
    Contributor

    @mjaffa-figure
    To confirm what's wrong, we may need a demo project to reproduce it.

  14. 50 remaining items

  15. mjaffa-figure commented on Jul 20, 2019

    @mjaffa-figure
    Author

    @cbracken @dnfield @zoechi Anything being done about this issue? Is there a way you can make a feature to have it load images on the CPU like before where I could load up this many resources?

  16. mjaffa-figure commented on Jul 26, 2019

    @mjaffa-figure
    Author

    Still no more info on this???? I ran all the png assets I use through tinyPNG. It reduced all my assets by 71%, shaved off a lot of memory being loaded in my game on Flutter. But still crashes on iPhone SE. This is pretty sad. I miss the images being processed on the CPU rather than the GPU.

  17. dnfield commented on Jul 26, 2019

    @dnfield
    Contributor

    This is probablythe same bug as #32143.

    Is this still reproducing on master?

    Are you able to work around it by precaching any images you want to display? Reducing the PNG size isn't what matters, it's the raw size of the image decoded.

  18. mjaffa-figure commented on Jul 26, 2019

    @mjaffa-figure
    Author

    @dnfield
    Yeah I just tried master, still crashing. I precache everything that I am going to use throughout the game in my assets class while the splash screen is showing

    I don't cache anywhere close to the amounts of memory they list the iPhone SE should have access to in this article.

    https://stackoverflow.com/questions/5887248/ios-app-maximum-memory-budget

  19. mtjaffacode commented on Aug 12, 2019

    @mtjaffacode

    @dnfield @cbracken
    This is pretty sad, it is crashing on an iPhone8 in both flutter channel stable and flutter channel master. With memory issues. Can we just have an option of switching between CPU and GPU image loading. Worked just fine in flutter 1.1.8 before the switch.

  20. maxermakov commented on Aug 21, 2019

    @maxermakov

    @dnfield @cbracken Hi, maybe you could provide some forecasts about such issues pls? I'm using few listviews containing CachedNetworkImages, should I start to think about some workarounds or NetworkImages became available for usage in flutter soon?

  21. dnfield commented on Feb 26, 2020

    @dnfield
    Contributor

    We've made a number of improvements since this issue was opened that should help.

    Unfortunately, it's very likely that you just simply cannot cache that many images at full resolution without running out of memory, particularly on devices with lower member (like iPhones).

    I'm a bit curious about why GPU/CPU decoding makes a difference. I'm pretty sure I experimented with changing that back and it still caused the crash (although I think it made the crash slightly harder to reproduce, probably because it was just slower). At any rate, some of the changes made since this bug was opened should make it easier to avoid the crash again, but still require that you not try to cache all of those images decompressed.

  22. dnfield commented on Feb 26, 2020

    @dnfield
    Contributor

    @mjaffa-figure - if you're still pursing this project, did you work around this, or are you still experiencing the issue?

  23. dnfield commented on Feb 26, 2020

    @dnfield
    Contributor

    In answer to my own question, yes, the test project still crashes on master.

  24. dnfield commented on Feb 26, 2020

    @dnfield
    Contributor

    So here's the breakdown:

    • Before the identifi engine change, we did not properly allow usage of cross context images. Using cross context images makes things faster, but uses slightly more memory - partly because of mipmapping and partly because we're allocating some texture memory for it up front.
    • Now, cross context images are used correctly.

    Before the change, the example app in this issue was very close to being OOM killed by the OS. On my local tests without the engine change, it's allocating just under 2GB of memory, which is shockingly not enough to get OOM killed.

    After the change, we're now just over the threshhold. However, the sample app is just very dangerous to run - it's decoding 576 1219x708 8bit RGBA images - that's a lot of memory to decode all at once!

    Some things that should be done instead:

    • Decode fewer images at once. Instead of pre-loading all 576 images, load only the ones needed for the current and/or next screen. Preload new images on demand, and make sure to let go of images that you don't need anymore.
    • Decode smaller images - including using ResizeImage to downsample the image being used closer to the actual size you will render the image at.

    I'm going to close this bug as WAI. It's unfortunate that an app that used to work stopped working, but to be honest the app that used to work was really hanging on by a thread and was never safe to run anyway - any device with say less than 2GB of total RAM will crash with it.

  25. mjaffa-figure commented on Feb 27, 2020

    @mjaffa-figure
    Author

    @dnfield
    Thanks, lower resolution images work great and no crashing. It was crazy to have that high of resolution images on an iPhone 5 anyways.

    Thanks!

  26. github-actions commented on Aug 8, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  27. locked as resolved and limited conversation to collaborators on Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: imagesLoading, displaying, rendering imagesc: crashStack traces logged to the consolec: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions