Modern Apps git

← Modern-Apps.git

maps: sleep instead of yield-spin in awaitSelection

Commit
c455ac98cca65966001a9384733611dc9481f133
Author
Vayun Mathur <[email protected]>
When
2026-11-17 02:44 UTC (19 days ago)
Parents
8446c2b
awaitSelection spun Thread.yield() 500 times pumping only the main looper; the offline search and suspending toFeature conversion run on Dispatchers.IO, and on a loaded box the spin burned its budget before the IO thread was scheduled, so the selection read null at the assertion.

Sleep 10ms per iteration so IO gets scheduled. This helper backs every MainActivitySlice3 selection test.

Verified: TZ=UTC query-only place link test green.

Diff

maps/src/test/java/com/vayunmathur/maps/MainActivitySlice3Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/MainActivitySlice3Test.kt b/maps/src/test/java/com/vayunmathur/maps/MainActivitySlice3Test.ktindex 656903348c..b1d3bfb5aa 100644--- a/maps/src/test/java/com/vayunmathur/maps/MainActivitySlice3Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/MainActivitySlice3Test.kt@@ -571,7 +571,12 @@ class MainActivitySlice3Test {             Robolectric.flushForegroundThreadScheduler()             shadow.idle()             if (openedOf(vm) != null) return-            Thread.yield()+            // Sleep, not yield: the offline search and the suspending+            // toFeature/osmPlace conversion run on Dispatchers.IO, and a+            // yield-spin on a loaded box burns its whole iteration budget+            // before the IO thread is ever scheduled (the selection then+            // reads null / a stale sheet route at the assertion).+            Thread.sleep(10)         }     }