fix(BlockList): fix race condition in BlockList #185
Merged
+291
−58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes race conditions in the BlocksList component and scheduler system that prevented HTML blocks from rendering when tabs were opened in the background or when debounced functions were called recursively.
1. Background Tab Rendering Issue
When a browser tab was opened in the background, HTML blocks would not render until the user interacted with the page. This was caused by browsers pausing or throttling
requestAnimationFramecalls in inactive tabs.Solution
visibilitychangeevent inGlobalSchedulerperformUpdate()if the scheduler is running2. Race Condition in debounce/throttle
When a debounced or throttled function triggered new calls to itself during execution, the state management could lead to conflicts due to incorrect operation ordering.
Solution
removeSchedulerreference3. Performance Optimization (
BlocksList.tsx)Replaced
lodash.isEqual+ sort with Set-based comparison for better performance on small to medium lists (10-100 blocks).Performance gains (see benchmarks):