Fix hierarchy generator logs freezing app #1351
Merged
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.
Description
Another attempt at mitigating the freezing caused by spamming the logs in a loop. This time it was caused by the hierarchy generator running in a loop, and since hooks cannot be used here, I changed the way it logs only once. Now, there are new functions
window.logErrorOnce
which will check a set for a key first, and only log if it is a new message. Additionally, I am now debouncing the redux calls by temporarily storing log messages in a simple array first, to prevent ever spamming so hard that the entire page freezes. If you accidentally uselogError
instead oflogErrorOnce
in a React component render function, it will not cause a state change immediately and should not cause a blocking loop freezing the page anymore (though the logs will get a lot of messages after a while).Related Issue(s)
Verification/QA
src/layout/layout.d.ts
andlayout.schema.v1.json
, and these are all backwards-compatiblekind/*
label to this PR for proper release notes grouping