Closed kmadsen closed 2 years ago
@kmadsen we indeed require MapboxMap to be called from the main thread only. In Debug builds we have a check that will throw an exception, however in Release it won't.
Btw - is Xiaomi you're running fully stopping Main thread when app is in BG (or only Choreographer is stopped) ? Is it possible to post
animation updates to main?
Is it possible to post animation updates to main?
It's the Choreographer.getInstance().postFrameCallback
that needs to be posted by a background thread.
A callstack example is through Animator.start
Choreographer.getInstance().postFrameCallback
-- AnimationHandler.addAnimationFrameCallback
--|-- ValueAnimator.start()
@yunikkk Why not make it so MapboxMap
will declare the main thread when the call stack reaches Mapbox domain in the CameraAnimationsPluginImpl?
@yunikkk Why not make it so
MapboxMap
will declare the main thread when the call stack reaches Mapbox domain in the CameraAnimationsPluginImpl?
That's definitely possible, guess we just hadn't seen a reason to allow animator to run from the BG thread and post updates to main internally.
It's the
Choreographer.getInstance().postFrameCallback
that needs to be posted by a background thread.
Not sure I follow, you're saying that Choreographer is working on the BG thread? I was asking whether MainThread's looper itself is working and simple mainHandler.post
will be handled while app is in bg. Guess it is, since platform android views (eg speed limit) are updating
Not sure I follow, you're saying that Choreographer is working on the BG thread? I was asking whether MainThread's looper itself is working and simple mainHandler.post will be handled while app is in bg. Guess it is, since platform android views (eg speed limit) are updating
On Xiaomi, calls to Choreographer.postFrameCallback
are ignore when called from the main thread (only when the app is put into background). The MIUI has a unique Choreographer
with this behavior. https://github.com/mapbox/mapbox-maps-android/issues/1413. Some execution is needed in order to see animations or render updates by Android Auto head units.
The MapboxRenderThread is working on Xiaomi devices for this reason, it is posting the frame calls from a background thread.
Could be closed as the approach was revisited in https://github.com/mapbox/mapbox-maps-android/pull/1638.
When testing solutions for this https://github.com/mapbox/mapbox-maps-android/issues/1413
Ran into this crash
Verifying ValueAnimator works on background thread
Here is the code I used to verify that ValueAnimator is designed to work on a background thread. This code can be used in an app without mapbox to create animations. It's the mapbox
WorkerThreadException
that is preventing downstream from using a background thread for camera animations.