Skip to content

Commit

Permalink
Fix spamming log in renderer (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiryldz authored Oct 29, 2024
1 parent 0e23a31 commit e85ad7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal val nonRenderEventQueue = ConcurrentLinkedQueue<RenderEvent>()

private var surface: Surface? = null
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal var surface: Surface? = null
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal var eglSurface: EGLSurface
private var width: Int = 0
Expand Down Expand Up @@ -663,7 +664,7 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
logI(TAG, "Setting up render thread failed, check logs above.")
}
}
} else {
} else if (!paused) {
logI(TAG, "renderThreadPrepared=false and Android surface is not valid (isValid=${surface?.isValid}). Waiting for new one.")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,4 +1065,21 @@ class MapboxRenderThreadTest {
mapboxRenderer.destroyRenderer()
}
}

@Test
fun noLogSpamDuringPauseTest() {
initRenderThread()
provideValidSurface()
mapboxRenderThread.pause()
// easiest way to simulate that Android surface is not valid
mapboxRenderThread.surface = null
mapboxRenderThread.eglContextMadeCurrent = false
idleHandler()
// make sure we do not print any logI
every { logI(any(), any()) } answers { throw RuntimeException() }
// simulate engine sending request render while we are paused
mapboxRenderThread.queueRenderEvent(MapboxRenderer.repaintRenderEvent)
idleHandler()
every { logI(any(), any()) } answers { Log.i(firstArg(), secondArg()) }
}
}

0 comments on commit e85ad7d

Please sign in to comment.