mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
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:
1 parent
d991d99e0f
commit
123cbf06e7
1 file changed
+6
@@ -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) {
|
||||
mainHandler.post {
|
||||
Choreographer.getInstance().postFrameCallback { callback() }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user