public class DidJSUpdateUiDuringFrameDetector extends java.lang.Object implements NotThreadSafeBridgeIdleDebugListener, NotThreadSafeViewHierarchyUpdateDebugListener
ReactBridge
and a UIManagerModule
,
getDidJSHitFrameAndCleanup(long, long)
should be called once per frame via a
Choreographer.FrameCallback
.Constructor and Description |
---|
DidJSUpdateUiDuringFrameDetector() |
Modifier and Type | Method and Description |
---|---|
boolean |
getDidJSHitFrameAndCleanup(long frameStartTimeNanos,
long frameEndTimeNanos)
Designed to be called from a
Choreographer.FrameCallback#doFrame call. |
void |
onTransitionToBridgeBusy()
Called when the bridge was in an idle state and executes a JS call or callback.
|
void |
onTransitionToBridgeIdle()
Called once all pending JS calls have resolved via an onBatchComplete call in the bridge and
the requested native module calls have also run.
|
void |
onViewHierarchyUpdateEnqueued()
Called when
UIManagerModule enqueues a UI batch to be dispatched to the main thread. |
void |
onViewHierarchyUpdateFinished()
Called from the main thread after a UI batch has been applied to all root views.
|
public void onTransitionToBridgeIdle()
NotThreadSafeBridgeIdleDebugListener
onTransitionToBridgeIdle
in interface NotThreadSafeBridgeIdleDebugListener
public void onTransitionToBridgeBusy()
NotThreadSafeBridgeIdleDebugListener
onTransitionToBridgeBusy
in interface NotThreadSafeBridgeIdleDebugListener
public void onViewHierarchyUpdateEnqueued()
NotThreadSafeViewHierarchyUpdateDebugListener
UIManagerModule
enqueues a UI batch to be dispatched to the main thread.onViewHierarchyUpdateEnqueued
in interface NotThreadSafeViewHierarchyUpdateDebugListener
public void onViewHierarchyUpdateFinished()
NotThreadSafeViewHierarchyUpdateDebugListener
onViewHierarchyUpdateFinished
in interface NotThreadSafeViewHierarchyUpdateDebugListener
public boolean getDidJSHitFrameAndCleanup(long frameStartTimeNanos, long frameEndTimeNanos)
Choreographer.FrameCallback#doFrame
call.
There are two 'success' cases that will cause getDidJSHitFrameAndCleanup(long, long)
to
return true for a given frame:
1) UIManagerModule finished dispatching a batched UI update on the UI thread during the frame.
This means that during the next hierarchy traversal, new UI will be drawn if needed (good).
2) The bridge ended the frame idle (meaning there were no JS nor native module calls still in
flight) AND there was no UiManagerModule update enqueued that didn't also finish. NB: if
there was one enqueued that actually finished, we'd have case 1), so effectively we just
look for whether one was enqueued.
NB: This call can only be called once for a given frame time range because it cleans up
events it recorded for that frame.
NB2: This makes the assumption that onViewHierarchyUpdateEnqueued is called from the
UIManagerModule.onBatchComplete()
, e.g. while the bridge is still considered busy,
which means there is no race condition where the bridge has gone idle but a hierarchy update is
waiting to be enqueued.frameStartTimeNanos
- the time in nanos that the last frame startedframeEndTimeNanos
- the time in nanos that the last frame ended