https://kotlinlang.org logo
#compose-android
Title
# compose-android
m

Marko Novaković

10/23/2023, 10:12 PM
I’m facing performance issue with
google-maps-compose
.
Compose
1-1 copy of
View
map version has terrible performance with same data set. problem is with clustering and cluster items. everything works fine until I zoom in to the point where individual cluster items show. when individual cluster items should be showing app just freezes and gives me ANRs. it even freezes when there is cluster with 5 items and when I zoom to see those 5 items. I tested with 100 and 150 markers/cluster items and it works perfectly fine. I don’t know the threshold when issue starts appearing. log shows 800, 1000, 1500 frames skipped one after another. cluster item are custom markers/xml vector icons. exactly the same xml vector icons are used in View system map version. somebody faced same issue? any suggestions?
u

Ulf

10/24/2023, 6:08 AM
I also had terrible performance with google-maps-compose in dev build, thought it was my code but tried copying the sample activity here: https://github.com/googlemaps/android-maps-compose/blob/main/app/src/main/java/com/google/maps/android/compose/BasicMapActivity.kt And there still was a major performance issue, practically unusable when trying to zoom and pan. I then found this: https://github.com/googlemaps/android-maps-compose/issues/159 My app is currently using
Copy code
StrictMode.ThreadPolicy.Builder()
    .detectAll()
When I changed to
Copy code
StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .permitDiskReads()
The lagging is gone!! Not a solution - but a workaround that worked for me...
I think I will use this where i have the GoogleMap:
Copy code
if (strictModeEnabled) {
    DisposableEffect(Unit) {
        val prevThreadPolicy = StrictMode.allowThreadDiskReads()
        onDispose {
            StrictMode.setThreadPolicy(prevThreadPolicy)
        }
    }
}
m

Marko Novaković

10/24/2023, 7:56 AM
interesting “fix”
🤠 1
hmmm
it skips frames even when I zoom to 5 item clustered item and it freezes and gives ANR when I those 5 should expand
u

Ulf

10/24/2023, 8:00 AM
does this happen to you without strictmode enabled?
m

Marko Novaković

10/24/2023, 8:02 AM
without yes, I’ll try to do
permitDiskReads
right now
but that helps only for debug builds, release builds work fine?
u

Ulf

10/24/2023, 8:04 AM
yeah only debug builds, and it's not enabled by default afaik, so only if you somewhere explicitly enable threadpolicy detectAll or detectDiskReads it will help to disable it...
m

Marko Novaković

10/24/2023, 8:14 AM
doesn’t work for me
it’s still unusable
😢 2
5 Views