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

Bypass isConnected checks when destroying FIE #17890

Merged
merged 2 commits into from Sep 6, 2018

Conversation

jridgewell
Copy link
Contributor

@jridgewell jridgewell commented Sep 5, 2018

This may be the cause of all the "window is null" bugs...

Introduced in #13945, we started to ignore disconnectedCallbacks when the node itself was still connected to a document. But, FIE's destroy themselves and try to clean up Resources even though those resources are still connected to the FIE's document. So, we would end up ignoring the disconnect, leaving all of them in memory and active.

Fixes #17839.
Fixes #15883.
Fixes #17604.
Probably more... Anything that touches FIE.

Fixes (maybe) #9177?
Fixes (maybe) #17840?

Working on tests now.

This may be the cause of all the "window is null" bugs...
* Called when an element is disconnected from DOM, or when an ampDoc is
* being disconnected (the element itself may still be connected to ampDoc).
*
* This does not guard against connected elements.

Choose a reason for hiding this comment

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

This is confusing since we still check this.isConnected_. Maybe rename that variable to connectedCallbackWasCalled_?

*
* This does not guard against connected elements.
*/
disconnect() {

Choose a reason for hiding this comment

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

I think using opt_force = false or opt_checkDom = true param in disconnectedCallback is more readable. Then add a comment to resource.js about why we pass false in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jridgewell jridgewell merged commit c817425 into ampproject:master Sep 6, 2018
@jridgewell jridgewell deleted the disconnect-fie branch September 6, 2018 00:41
@jridgewell jridgewell added this to Done in Runtime Sep 6, 2018
@jridgewell jridgewell added this to To do in Make Malte, Dima, Justin Happy via automation Sep 6, 2018
@jridgewell jridgewell moved this from To do to Done in Make Malte, Dima, Justin Happy Sep 6, 2018
@cathyxz
Copy link
Contributor

cathyxz commented Sep 10, 2018

@jridgewell @choumx is this PR important enough to cherry pick into the current release before promoting to production? All of these referenced issues are present in current canary at relatively high error rates.

Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Bypass isConnected checks when destroying FIE

This may be the cause of all the "window is null" bugs...

* Tests and reviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants