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

ComposeNotIdleException with rememberClusterRenderer and clusterContent=null #579

Open
vinipazzini opened this issue Jun 6, 2024 · 0 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@vinipazzini
Copy link

Thanks for stopping by to let us know something could be better!

Please be sure to include as much information as possible:

Environment details

  1. Clustering
  2. MacOS 14.4.1 (23E224)
  3. com.google.maps.android:maps-compose:5.0.1 com.google.maps.android:maps-compose-utils:5.0.1
  4. I am not stating other libraries because I am using this very project as base

Steps to reproduce

  1. Apply the patch below to the project
  2. Run the testStartingCameraPosition test
  3. Test Fails with ComposeNotIdleException: Idling resource timed out: possibly due to compose being busy
  4. If you revert clusterContent = null to its original state the test is green
clusterContent = { cluster ->
   CircleContent(
       modifier = Modifier.size(40.dp),
       text = "%,d".format(cluster.size),
       color = Color.Green,
   )
},

Code example

Subject: [PATCH] Reproduce idling issue
---
Index: app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt b/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt
--- a/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt	(revision 9a6712f25f0a80a979a110effb86270a94e1d10c)
+++ b/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt	(date 1717668743759)
@@ -15,10 +15,8 @@
 package com.google.maps.android.compose
 
 import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.material.Text
 import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
 import androidx.compose.ui.test.assertIsDisplayed
 import androidx.compose.ui.test.junit4.createComposeRule
 import androidx.compose.ui.test.onNodeWithTag
@@ -26,12 +24,13 @@
 import androidx.compose.ui.test.performClick
 import com.google.android.gms.maps.model.CameraPosition
 import com.google.android.gms.maps.model.LatLng
-import org.junit.Assert.*
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertTrue
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
 
 class GoogleMapViewTests {
     @get:Rule
@@ -43,20 +42,9 @@
 
     private fun initMap(content: @Composable () -> Unit = {}) {
         check(hasValidApiKey) { "Maps API key not specified" }
-        val countDownLatch = CountDownLatch(1)
         composeTestRule.setContent {
-            GoogleMapView(
-                modifier = Modifier.fillMaxSize(),
-                cameraPositionState = cameraPositionState,
-                onMapLoaded = {
-                    countDownLatch.countDown()
-                }
-            ) {
-                content.invoke()
-            }
+            GoogleMapClustering()
         }
-        val mapLoaded = countDownLatch.await(30, TimeUnit.SECONDS)
-        assertTrue("Map loaded", mapLoaded)
     }
 
     @Before
Index: app/src/main/java/com/google/maps/android/compose/MarkerClusteringActivity.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/src/main/java/com/google/maps/android/compose/MarkerClusteringActivity.kt b/app/src/main/java/com/google/maps/android/compose/MarkerClusteringActivity.kt
--- a/app/src/main/java/com/google/maps/android/compose/MarkerClusteringActivity.kt	(revision 9a6712f25f0a80a979a110effb86270a94e1d10c)
+++ b/app/src/main/java/com/google/maps/android/compose/MarkerClusteringActivity.kt	(date 1717668337228)
@@ -74,7 +74,7 @@
 @Composable
 fun GoogleMapClustering(items: List<MyItem>) {
     var clusteringType by remember {
-        mutableStateOf(ClusteringType.Default)
+        mutableStateOf(ClusteringType.CustomRenderer)
     }
     GoogleMap(
         modifier = Modifier.fillMaxSize(),
@@ -187,13 +187,7 @@
         )
     )
     val renderer = rememberClusterRenderer(
-        clusterContent = { cluster ->
-            CircleContent(
-                modifier = Modifier.size(40.dp),
-                text = "%,d".format(cluster.size),
-                color = Color.Green,
-            )
-        },
+        clusterContent = null,
         clusterItemContent = {
             CircleContent(
                 modifier = Modifier.size(20.dp),

Stack trace

androidx.compose.ui.test.junit4.android.ComposeNotIdleException: Idling resource timed out: possibly due to compose being busy.
IdlingResourceRegistry has the following idling resources registered:
- [busy] ComposeIdlingResource is busy due to pending measure/layout.

All registered idling resources: Compose-Espresso link
at androidx.compose.ui.test.junit4.EspressoLink_androidKt.rethrowWithMoreInfo(EspressoLink.android.kt:136)
at androidx.compose.ui.test.junit4.EspressoLink_androidKt.runEspressoOnIdle(EspressoLink.android.kt:110)
at androidx.compose.ui.test.junit4.EspressoLink.runUntilIdle(EspressoLink.android.kt:79)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.waitForIdle(ComposeUiTest.android.kt:340)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$waitForIdle(ComposeUiTest.android.kt:230)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidComposeUiTestImpl.waitForIdle(ComposeUiTest.android.kt:410)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidComposeUiTestImpl.setContent(ComposeUiTest.android.kt:489)
at androidx.compose.ui.test.junit4.AndroidComposeTestRule.setContent(AndroidComposeTestRule.android.kt:340)
at com.google.maps.android.compose.GoogleMapViewTests.initMap(GoogleMapViewTests.kt:46)
at com.google.maps.android.compose.GoogleMapViewTests.initMap$default(GoogleMapViewTests.kt:43)
at com.google.maps.android.compose.GoogleMapViewTests.testStartingCameraPosition(GoogleMapViewTests.kt:65)
... 53 trimmed
Caused by: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [Compose-Espresso link] to become idle timed out
at androidx.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:4)
at androidx.test.espresso.base.UiControllerImpl$5.resourcesHaveTimedOut(UiControllerImpl.java:1)
at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleTimeout(IdlingResourceRegistry.java:4)
at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleMessage(IdlingResourceRegistry.java:6)
at android.os.Handler.dispatchMessage(Handler.java:103)
at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:14)
at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:8)
at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:16)
at androidx.test.espresso.Espresso$1.run(Espresso.java:1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
@vinipazzini vinipazzini added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
1 participant