Account for race conditions with stream intercetor
Summary: Given that stream interceptor is async the folling race conditino could occur. Frame at time t=0 comes in, we yeild to the event loop while fetching metadata, fetch takes 5 ticks Frame at time t=1 comes in, we yeild to the event loop but fetch takes 1 tick At time t=2 the second frame is augmented and display At time t=5 the first fetch returns and we display and older frame This is a simple check to avoid this. Reviewed By: aigoncharov Differential Revision: D45314013 fbshipit-source-id: 054e7e6beb52dfbfd94bc9f8ee3d0a758a669f66
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7ce19f4359
commit
862592e03d
@@ -63,6 +63,7 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
const metadata = createState<Map<MetadataId, Metadata>>(new Map());
|
const metadata = createState<Map<MetadataId, Metadata>>(new Map());
|
||||||
const streamInterceptor = getStreamInterceptor();
|
const streamInterceptor = getStreamInterceptor();
|
||||||
|
|
||||||
|
let lastFrameTime = 0;
|
||||||
const device = client.device.os;
|
const device = client.device.os;
|
||||||
|
|
||||||
client.onMessage('init', (event) => {
|
client.onMessage('init', (event) => {
|
||||||
@@ -249,7 +250,10 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
applyFrameData(processedNodes, frameScan.snapshot);
|
if (frameScan.frameTime > lastFrameTime) {
|
||||||
|
applyFrameData(processedNodes, frameScan.snapshot);
|
||||||
|
lastFrameTime = frameScan.frameTime;
|
||||||
|
}
|
||||||
|
|
||||||
applyFrameworkEvents(frameScan);
|
applyFrameworkEvents(frameScan);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user