mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17: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
|
package dev.uatu.sdk
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.Choreographer
|
import android.view.Choreographer
|
||||||
|
|
||||||
class ChoreographerPoster : FrameCallbackPoster {
|
class ChoreographerPoster : FrameCallbackPoster {
|
||||||
|
private val mainHandler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
override fun postFrameCallback(callback: () -> Unit) {
|
override fun postFrameCallback(callback: () -> Unit) {
|
||||||
|
mainHandler.post {
|
||||||
Choreographer.getInstance().postFrameCallback { callback() }
|
Choreographer.getInstance().postFrameCallback { callback() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user