Fix OM 862 - Race condition between schedule-render! and send cb's reconcile! that prevents some future reconciling #863
+57
−3
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:
In particular,
(merge! ...)
will cause a state change that can trigger a(schedule-render! ...)
and therefore eventually a reconcile. In cases where therequestAnimationFrame
immediately runs the scheduled reconcile, "eventually" becomes "immediately." During this immediate reconcile, the following line will set:queued
tofalse
: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
:queued
back totrue
, without adding enqueueing anything to:queue-remote
or: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
:state
won't trigger a reconcile. See here:And the symptom will be observed state changes not re-rendering our ui.