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

BasicAlertDialog Crash iOS with OOM (Memory Leak) #4852

Closed
chrisjenx opened this issue May 22, 2024 · 15 comments
Closed

BasicAlertDialog Crash iOS with OOM (Memory Leak) #4852

chrisjenx opened this issue May 22, 2024 · 15 comments
Assignees
Labels
bug Something isn't working crash ios memory leak

Comments

@chrisjenx
Copy link

chrisjenx commented May 22, 2024

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:

Screenshot 2024-05-22 at 5 38 33 PM

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:

  1. Open Dialog with scrollable content
  2. Scroll Content very slowly, app will crash after it runs out of memory drawing

Expected behavior
Don't OOM and crash on iOS

Screenshots
Screenshot 2024-05-22 at 5 38 33 PM

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

@chrisjenx chrisjenx added bug Something isn't working submitted labels May 22, 2024
@mazunin-v-jb
Copy link
Contributor

mazunin-v-jb commented May 23, 2024

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?

@mazunin-v-jb mazunin-v-jb added the wait for reply Further information is requested label May 23, 2024
@chrisjenx
Copy link
Author

Yeah we're working on deploying a hot fix to users once that's done I'll create a sample for y'all

@chrisjenx
Copy link
Author

Added Trace, easy to reproduce, any dialog with scrollable content, scroll SLOWLY and you'll eventually run out of memory

@mazunin-v-jb mazunin-v-jb removed the wait for reply Further information is requested label May 23, 2024
@mazunin-v-jb
Copy link
Contributor

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?

@mazunin-v-jb mazunin-v-jb added the wait for reply Further information is requested label May 23, 2024
@chrisjenx
Copy link
Author

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

@chrisjenx
Copy link
Author

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)

@chrisjenx
Copy link
Author

chrisjenx commented May 25, 2024

@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

@chrisjenx chrisjenx changed the title Dialogs Crash iOS with OOM (Memory Leak) BasicAlertDialog Crash iOS with OOM (Memory Leak) May 25, 2024
@chrisjenx
Copy link
Author

Nvm mind, I tested on the foundation Dialog and the same thing, guessing it's an underlying skia issue from what I can tell.

@mazunin-v-jb mazunin-v-jb removed the wait for reply Further information is requested label May 27, 2024
@mazunin-v-jb
Copy link
Contributor

@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

@chrisjenx
Copy link
Author

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

@chrisjenx
Copy link
Author

@mazunin-v-jb I will give 1.6.11 ago, I'm wondering if this was the cause of the OOM JetBrains/compose-multiplatform-core#1355

@chrisjenx
Copy link
Author

chrisjenx commented Jun 5, 2024

Tested 1.6.11, still crashing for me. Looks like it's something else :(

(It's actually worse after some more testing)

@chrisjenx
Copy link
Author

Initial testing, looks like JetBrains/compose-multiplatform-core#1390 fixed it, just running profiling now.

@chrisjenx
Copy link
Author

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.

@chrisjenx
Copy link
Author

Looks like this is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash ios memory leak
Projects
None yet
Development

No branches or pull requests

3 participants