JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.99k stars 1.16k forks source link

Compose on iOS resulting huge memory and CPU consumption resulting in ios app crashing, phone warming and freezing issues #4912

Closed sureshmaidaragi1919 closed 3 months ago

sureshmaidaragi1919 commented 4 months ago

Describe the problem

In our project, we are seeing two blocker issues, High CPU and Memory consumption on iOS app due to which we have halted the project development until it is resolved. Videos attached here is from our code base, and code base attached for sample demo to reproduce the issue.

Memory consumption issue

We are loading simple Bottomsheet dialog around 10 to 15 times on screen, on each instance it results in 3MB increase and 3MB is not releasing at all even if we come back from the screen

CPU consumption issue:

When a particular job is done by app, immediately CPU should return to 0-1%, which is not happening. in our usecase CPU utlisiation going up to 180% and returning to ~104% and staying in ~104% for around 1min later coming back to 0-1% if app is idle.

Affected platforms Select one of the platforms below:

If the problem is Android-only, report it in the Jetpack Compose tracker

Versions

Sample code Sample project code link

Reproduction steps Please provide a detailed step-by-step guide on how to reproduce the issue you are experiencing.

Video video link

Profiling data Please provide any relevant profiling data that might be helpful. This could include information like FPS, memory usage, CPU time, or any other data that could provide insight into the performance issue. Screenshot 2024-05-31 at 3 16 10 PM Screenshot 2024-05-31 at 6 13 42 PM Screenshot 2024-05-31 at 8 08 31 PM

Additional information

terrakok commented 3 months ago

Hi. Thank you for the report. We will investigate it soon and will ask you more information if it is required

elijah-semyonov commented 3 months ago

@sureshmaidaragi1919

turning to ~104% and staying in ~104% for around 1min

Can you make a screenshot of all the active threads when this happens? I can't reproduce it.

sureshmaidaragi1919 commented 3 months ago

here it is @elijah-semyonov https://drive.google.com/file/d/1-pEe6-UZcy6NGJLgrbNgNb7LdEZCIS3B/view?usp=sharing

sureshmaidaragi1919 commented 3 months ago

High CPU was due to Xcode Edit config on debug build, @elijah-semyonov thanks for the suggestion 🙌 🥳 .

Solution: uncheck the below options Main Thread Checker Thread Performance Checker

Screenshot 2024-06-03 at 6 52 32 PM
terrakok commented 3 months ago

Apple root issue: https://discussions.apple.com/thread/255578878?sortBy=best

sureshmaidaragi1919 commented 3 months ago

There is memory consumption issue that still persists on compose 1.6.10, when I navigate between two simple screens, it does not completely drop the retained memory when I move back from the screen.

Is there any workaround for this?

terrakok commented 3 months ago

You are supposed

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.