fix(sdk-android): post frame callbacks via main looper

Choreographer.getInstance() is per-thread and throws on threads
without a Looper. The previous impl called it from the SocketClient
reader thread, which surfaced as snapshot failures with empty
state during the sample-app round trip. Now the reader thread
posts a Runnable to the main Handler that, on the main thread,
gets the Choreographer and posts the frame callback.
This commit is contained in:
pj committed 2026-04-17 23:39:11 +07:00
1 parent d991d99e0f
commit 123cbf06e7
1 file changed
+7 -1
@@ -1,9 +1,15 @@
package dev.uatu.sdk
import android.os.Handler
import android.os.Looper
import android.view.Choreographer
class ChoreographerPoster : FrameCallbackPoster {
private val mainHandler = Handler(Looper.getMainLooper())
override fun postFrameCallback(callback: () -> Unit) {
Choreographer.getInstance().postFrameCallback { callback() }
mainHandler.post {
Choreographer.getInstance().postFrameCallback { callback() }
}
}
}