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

Eliminate a frameback navigation initialization race #518

Merged
merged 1 commit into from
Aug 10, 2016

Conversation

gigabo
Copy link
Contributor

@gigabo gigabo commented Aug 10, 2016

During the first frameback navigation forward with reuseFrame set, if the
client controller within the frame completes before the frame's load event
fires we were previously failing to wire up our listener to handle subsequent
navigations.

During the first frameback navigation forward with `reuseFrame` set, if the
client controller within the frame completes before the frame's load event
fires we were previously failing to wire up our listener to handle subsequent
navigations.
@gigabo gigabo added the bug An issue with the system label Aug 10, 2016
if (clientController && !clientController.__parentIsListening && !clientController._previouslyRendered) {
clientController.__parentIsListening = true;
clientController.context.onLoadComplete(this._handleFrameLoad.bind(this, frame));
if (clientController && !clientController._previouslyRendered) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be an else if block? or even an else block? clientController.__parentIsListening is set on the first load, as is clientController._previouslyRendered -- are the two separate checks because there's asynchrony and users may perform navigations before we've finished loading?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can this be an else if block? or even an else block?

It can't, actually. You'll notice that previously the bodies of the two cases were together, and the conditionals were anded. In the case where the frame's load event fires before the client controller finishes rendering we still need both to happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically: We always need to wire up our listener (once). And, in the case where the event we're listening to hasn't fired yet, we'll bail out early and wait for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's asynchrony and users may perform navigations before we've finished loading?

It's actually just a race between the browser's load event and the client controller finishing its render. No user interaction needed.

@doug-wade
Copy link
Collaborator

lgtm 👍

@gigabo gigabo merged commit 93c3f78 into redfin:master Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants