From 9ae632ba5c63430a8c0b347c58714e067b51dbb0 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Wed, 23 Aug 2023 07:09:04 -0700 Subject: [PATCH] Bloks apply frame and then augment Summary: Given that we have to retry aggressively to fetch reduciton traces the blok augmentation can take a longer time. For cases like embedded bloks this can slow down the ui debugger even if you arent debuggin bloks. To avoid this we display the frame immediatley and then asynchronously augment it. There is a possibility that you might see bloks bound tree nodes with no name briefly since this is this the state they come from the client as. This isnt the ideal solution as the better way would be to do the unminification first and then add the derived components (which depends on reduction trace) after. This avoid this qurik but is a much bigger refactor so will do it another time if needed Reviewed By: lblasa Differential Revision: D48600897 fbshipit-source-id: 06fc5c5ecc6fe575f815d3ebca685f363275c84c --- desktop/plugins/public/ui-debugger/index.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 2d3025f42..df3366769 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -210,10 +210,18 @@ export function plugin(client: PluginClient) { const processFrame = async (frameScan: FrameScanEvent) => { try { + const nodes = new Map( + frameScan.nodes.map((node) => [node.id, {...node}]), + ); + if (frameScan.frameTime > lastFrameTime) { + applyFrameData(nodes, frameScan.snapshot); + lastFrameTime = frameScan.frameTime; + } + applyFrameworkEvents(frameScan, nodes); + lastFrameTime = frameScan.frameTime; + const [processedNodes, additionalMetadata] = - await streamInterceptor.transformNodes( - new Map(frameScan.nodes.map((node) => [node.id, {...node}])), - ); + await streamInterceptor.transformNodes(nodes); metadata.update((draft) => { for (const metadata of additionalMetadata) { @@ -221,14 +229,10 @@ export function plugin(client: PluginClient) { } }); - if (frameScan.frameTime > lastFrameTime) { + if (frameScan.frameTime >= lastFrameTime) { applyFrameData(processedNodes, frameScan.snapshot); lastFrameTime = frameScan.frameTime; } - - applyFrameworkEvents(frameScan, processedNodes); - - return true; } catch (error) { pendingData.frame = frameScan; handleStreamError('Frame', error);