Repository navigation
Flutter crashed because of OOM #28037
Copy link
Copy link
Closed
Labels
a: imagesLoading, displaying, rendering imagesLoading, displaying, rendering imagesc: crashStack traces logged to the consoleStack traces logged to the consolec: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.
Description
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.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: imagesLoading, displaying, rendering imagesLoading, displaying, rendering imagesc: crashStack traces logged to the consoleStack traces logged to the consolec: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.
Activity
kangwang1988 commentedon Feb 16, 2019
Fail to reproduce this issue using the latest master.
mjaffa-figure commentedon Feb 16, 2019
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
kangwang1988 commentedon Feb 16, 2019
@mjaffa-figure
Can you paste the fail log?
mjaffa-figure commentedon Feb 16, 2019
@kangwang1988
This is the fail log:
kangwang1988 commentedon Feb 16, 2019
Duple of #16491
mjaffa-figure commentedon Feb 16, 2019
@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:
mjaffa-figure commentedon Feb 16, 2019
#16491 is a Flutter doctor issue. I have no problem with flutter doctor.
mjaffa-figure commentedon Feb 16, 2019
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?
mjaffa-figure commentedon Feb 16, 2019
@kangwang1988
kangwang1988 commentedon Feb 16, 2019
Leave it open as it seems different.
kangwang1988 commentedon Feb 16, 2019
@mjaffa-figure
To confirm what's wrong, we may need a demo project to reproduce it.
50 remaining items
mjaffa-figure commentedon Jul 20, 2019
@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?
mjaffa-figure commentedon Jul 26, 2019
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.
dnfield commentedon Jul 26, 2019
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.
mjaffa-figure commentedon Jul 26, 2019
@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
mtjaffacode commentedon Aug 12, 2019
@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.
maxermakov commentedon Aug 21, 2019
@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?
dnfield commentedon Feb 26, 2020
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.
dnfield commentedon Feb 26, 2020
@mjaffa-figure - if you're still pursing this project, did you work around this, or are you still experiencing the issue?
dnfield commentedon Feb 26, 2020
In answer to my own question, yes, the test project still crashes on master.
dnfield commentedon Feb 26, 2020
So here's the breakdown:
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:
ResizeImageto 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.
mjaffa-figure commentedon Feb 27, 2020
@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!
bhanuka96 commentedon Dec 24, 2020
@dnfield Hi, can you help me solve this issue? https://stackoverflow.com/questions/65405227/app-crash-on-low-performance-devices-when-loading-number-of-images
github-actions commentedon Aug 8, 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.