compose-multiplatform
compose-multiplatform copied to clipboard
`BasicAlertDialog` Crash iOS with OOM (Memory Leak)
Describe the bug
Since 1.6.10x, m3 BasicAlertDialogs with lots of content will recompose and leak memory causing out of memory crashes on iOS.
iOS will throw didReceiveMemoryWarning then crash:
More diagnostics to follow once got a sample project for you.
Affected platforms
- iOS
Versions
- Libraries:
- Compose Multiplatform version: 1.6.10 (or RC's)
- Decompose: 3.0
- Kotlin version: 1.9.23
- Device (model or simulator for iOS issues): Physical iPhone (Simulators do no crash) iOS 17.4
To Reproduce
More to follow, but full screen dialogs will recompose unconditionally and crash (will try and create a reproduction project for you)
Steps to reproduce the behavior:
- Open Dialog with scrollable content
- Scroll Content very slowly, app will crash after it runs out of memory drawing
Expected behavior Don't OOM and crash on iOS
Screenshots
Additional context I thought it was related to Kotlin 2.x but downgraded and still an issue, downgraded CMP to 1.6.1 and now not crashing.
Link to trace from Profling iOS App, looks like a Skia Canvas draw leak in 1.6.10. If you stop moving it will dealloc the objects, but scrolling slowly will not release quick enough.
https://drive.google.com/drive/folders/1UUPOyAWaeg7uTKaXc5EMCp-03jSy4hrk?usp=sharing
Hello! I'll notify the team about that, however, a small reproducible example would really help. Could you please attach it once you've made it to your first message?
Yeah we're working on deploying a hot fix to users once that's done I'll create a sample for y'all
Added Trace, easy to reproduce, any dialog with scrollable content, scroll SLOWLY and you'll eventually run out of memory
Unfortunately, I wasn't able to successfully reproduce this crash. Memory usage on a small project from template was about 70 mb and didn't increase no matter how I scrolled. Could you please make a reproducible example?
Unfortunately, I wasn't able to successfully reproduce this crash. Memory usage on a small project from template was about 70 mb and didn't increase no matter how I scrolled. Could you please make a reproducible example?
Dang, OK, will try and create a sample project. Sorry about that
Unfortunately, I wasn't able to successfully reproduce this crash. Memory usage on a small project from template was about 70 mb and didn't increase no matter how I scrolled. Could you please make a reproducible example?
Oh just checking this ONLY happens on a physical device, simulators are fine (faster/more ram from host machine)
@mazunin-v-jb As requested: DialogCrash.zip
Launch app on physical iPhone, open dialog, scroll slowly (will be jerky vs previous versions) and then will suddenly crash.
I should have noted it was the BasicAlertDialogs from the m3 lib
Nvm mind, I tested on the foundation Dialog and the same thing, guessing it's an underlying skia issue from what I can tell.
@chrisjenx many thanks! I haven't reproduced the crash, but the memory warning was received many times, and memory consumption is very weird. We'll look at it
Oh good, maybe a placebo, but 1.6.10 doesn't feel as smooth as 1.6.0 potentially related if it's over drawing, leaking, etc
@mazunin-v-jb I will give 1.6.11 ago, I'm wondering if this was the cause of the OOM https://github.com/JetBrains/compose-multiplatform-core/pull/1355
Tested 1.6.11, still crashing for me. Looks like it's something else :(
(It's actually worse after some more testing)
Initial testing, looks like https://github.com/JetBrains/compose-multiplatform-core/pull/1390 fixed it, just running profiling now.
So far looks like peak memory usage is 90mb on the demo project, no more OOM crashes, still churning memory but at least not exploding. Will test on my main project then close if doesn't crash there.
Looks like this is resolved
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.