Fix OM 862 - Race condition between schedule-render! and send cb's reconcile! that prevents some future reconciling#863
Open
bnoguchi wants to merge 4 commits intoomcljs:masterfrom
Open
Fix OM 862 - Race condition between schedule-render! and send cb's reconcile! that prevents some future reconciling#863bnoguchi wants to merge 4 commits intoomcljs:masterfrom
bnoguchi wants to merge 4 commits intoomcljs:masterfrom
Conversation
Otherwise, this doesn't work when merged with om-860 because the devcards for om-860 also exposes a race condition with the overriding om/*raf* we define in this branch.
Member
|
@bnoguchi thanks will review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 GH-862.
Right now, this block of code can result in a race condition that can stop future reconciling from occurring. Block of code inlined next for convenience:
([resp query remote] (when-not (nil? remote) (p/queue! this (keys resp) remote)) (merge! this resp query remote) (p/reconcile! this remote))))))))In particular,
(merge! ...)will cause a state change that can trigger a(schedule-render! ...)and therefore eventually a reconcile. In cases where therequestAnimationFrameimmediately runs the scheduled reconcile, "eventually" becomes "immediately." During this immediate reconcile, the following line will set:queuedtofalse:In this scenario, the last
(p/reconcile! this remote)in the code block above will run right after the reconcile triggered byrequestAnimationFrame. This reconcile will also call the following line:which will set
:queuedback totrue, without adding enqueueing anything to:queue-remoteor:queue.This puts our reconciler into a state in which subsequent calls to
schedule-render!will think that there is already a render scheduled and won't queue a render and reconcile.where
p/schedule-render!is defined as follows:This means that any reconciles that would result from a change in our reconciler
:statewon't trigger a reconcile. See here:And the symptom will be observed state changes not re-rendering our ui.