Skip to content

Commit 8334c9a

Browse files
natiginfogithub-actions[bot]
authored andcommitted
[maps-android] use non-render event (#5180)
GitOrigin-RevId: 15e35051c95f33761bbf37735dbadc0d15447303
1 parent 06b2f97 commit 8334c9a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

maps-sdk/src/main/java/com/mapbox/maps/renderer/MapboxRenderThread.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ import com.mapbox.maps.renderer.gl.TextureRenderer
2424
import com.mapbox.maps.renderer.widget.Widget
2525
import com.mapbox.maps.viewannotation.ViewAnnotationManager
2626
import com.mapbox.maps.viewannotation.ViewAnnotationUpdateMode
27-
import kotlinx.coroutines.DelicateCoroutinesApi
28-
import kotlinx.coroutines.GlobalScope
29-
import kotlinx.coroutines.delay
30-
import kotlinx.coroutines.launch
3127
import java.util.concurrent.ConcurrentLinkedQueue
3228
import java.util.concurrent.locks.Condition
3329
import java.util.concurrent.locks.ReentrantLock
@@ -717,15 +713,16 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
717713
logI(TAG, "Renderer paused")
718714
}
719715

720-
@OptIn(DelicateCoroutinesApi::class)
721716
@UiThread
722717
fun resume() {
723718
paused = false
724719
logI(TAG, "Renderer resumed, renderThreadPrepared=$renderThreadPrepared, surface.isValid=${surface?.isValid}")
725-
GlobalScope.launch {
726-
delay(RESET_THREAD_SERVICE_TYPE_DELAY_MS)
727-
mapboxRenderer.resetThreadServiceType()
728-
}
720+
postNonRenderEvent(
721+
RenderEvent({
722+
mapboxRenderer.resetThreadServiceType()
723+
}, false),
724+
RESET_THREAD_SERVICE_TYPE_DELAY_MS
725+
)
729726
// schedule render if we resume not after first create (e.g. bring map back to front)
730727
renderPreparedGuardedRun(::postPrepareRenderFrame)
731728
}

plugin-lifecycle/src/main/java/com/mapbox/maps/plugin/lifecycle/MapboxLifecyclePluginImpl.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal class MapboxLifecyclePluginImpl : MapboxLifecyclePlugin {
3131
val viewLifecycleRegistry = ViewLifecycleOwner(
3232
view = mapView
3333
)
34+
logI(TAG, "registerLifecycleObserver is called")
3435

3536
val componentCallback = object : ComponentCallbacks2 {
3637
override fun onConfigurationChanged(newConfig: Configuration) {
@@ -62,6 +63,7 @@ internal class MapboxLifecyclePluginImpl : MapboxLifecyclePlugin {
6263

6364
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
6465
fun onStop() {
66+
logI(TAG, "onStop is called, MapboxLifecycleObserver will be notified.")
6567
observer.onStop()
6668
}
6769

@@ -73,6 +75,7 @@ internal class MapboxLifecyclePluginImpl : MapboxLifecyclePlugin {
7375

7476
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
7577
fun onDestroy() {
78+
logI(TAG, "onDestroy is called, MapboxLifecycleObserver will be notified.")
7679
observer.onDestroy()
7780
viewLifecycleRegistry.lifecycle.removeObserver(this)
7881
viewLifecycleRegistry.cleanUp()

0 commit comments

Comments
 (0)