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

avoid jitter while resizing instructions #31222

Merged
merged 2 commits into from Oct 15, 2019

Conversation

davidsbailey
Copy link
Member

@davidsbailey davidsbailey commented Oct 11, 2019

Description

Fixes a bug in minecraft instructions as described here:

Repro steps

  1. zoom out to 90%
  2. navigate to a minecraft level
  3. press run
  4. press reset
  5. wait a while

usually, the screen becomes unresponsive by this point, and a few seconds later a "maximum stack depth exceeded" error appears. If you do not experience this, you can test whether the problem has been hit by running window.addEventListener('resize', function() {console.log('resize');} and pressing Run / Reset again.

Root cause

The root cause is that the instructions area can get into an infinite loop where it responds to its inputs changing by modifying the same input. In this particular case, it causes the renderedHeight to go up and down by 1 forever. The many resize events are secondary to this.

Solution

Only update the rendered height of the instructions if it is changing by more than 1. This eliminates the specific problem, but would not (for example) protect against other loops which modify the value by say +/- 2 on each iteration.

Testing story

Manually verified the issue is resolved. Since the repro steps are super-specific and involve changing the screen zoom level, I'm not adding a regression test to catch this exact problem.

Future work

LP-838 tracks implementing a more robust solution, by eliminating the potential feedback loop rather than just dampening it.

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@jmkulwik
Copy link
Contributor

Awesome. Looks like it'll definitely fix the break we're seeing. I pulled on my local machine, and didn't repro any issues with minecraft. I am a bit concerned about adding this workaround - are you planning to make a follow-up task to do a more in-depth fix and take out the workaround?

@davidsbailey
Copy link
Member Author

Great, thanks for verifying!

Yeah, we should have a follow-up for this: https://codedotorg.atlassian.net/browse/LP-838

@davidsbailey davidsbailey marked this pull request as ready for review October 14, 2019 20:27
@jmkulwik
Copy link
Contributor

LGTM. Although I am not very familiar with this space and would prefer someone from LP signed off instead of me.

@davidsbailey
Copy link
Member Author

makes sense @jmkulwik . In that case, @dmcavoy , can you also review?

Copy link
Contributor

@dmcavoy dmcavoy left a comment

Choose a reason for hiding this comment

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

Looks good Dave! Thanks for figuring this out as a work around for now

@davidsbailey davidsbailey merged commit d75e660 into staging Oct 15, 2019
@davidsbailey davidsbailey deleted the remove-instructions-jitter branch October 15, 2019 16:16
@jmkulwik jmkulwik mentioned this pull request May 1, 2020
7 tasks
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.

None yet

3 participants