Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use queueRender rather than render #10233

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Use queueRender rather than render #10233

merged 2 commits into from
Oct 15, 2024

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Oct 15, 2024

fixes microsoft/pxt-microbit#5989

replaces all of our calls to block.render() with block.queueRender().

for the linked bug, here's a timeline of what was happening:

  1. the duplicate function is invoked
  2. appendPrivate is called in Blockly to paste the blocks that are duplicated
  3. the root block (in this case a forever block) starts to initialize which causes its children to be added to the render queue
  4. each of the child blocks is initialized
  5. as part of the function call block's initialization, block.render() is called which immediately flushes the render queue
  6. the blocks in the render queue other than the function call are not actually rendered because they are marked as still initializing, but they are still removed from the queue
  7. the child initialization continues and all of the other blocks except for the math_number are re-added to the queue
  8. initialization completes and the final render takes place

the reason for step 7 where only math_number is left out of the render is pure coincidence caused by the order the blocks are initialized in; i'm sure there are many other setups that would have resulted in the same broken behavior. in any case, the fix is simple: queue the render instead of flushing the queue. i went ahead and made the same change everywhere we call .render() to prevent other similar bugs from cropping up (and hopefully improve perf slightly)

this definitely deserves some extra testing but i did a cursory pass over the affected blocks and fixed the only issue i encountered (the change to the focusLastEditor function in this PR).

@riknoll riknoll requested a review from a team October 15, 2024 20:31
Copy link
Contributor

@eanders-ms eanders-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@riknoll riknoll merged commit 9d326fc into master Oct 15, 2024
6 checks passed
@riknoll riknoll deleted the dev/riknoll/queue-render branch October 15, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicating a forever loop loses parameters on enclosed blocks
2 participants