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

Web Inspector: Assertion when removing event listener in CSSPropertyNameCompletions.js #3920

Conversation

rcaliman-apple
Copy link
Contributor

@rcaliman-apple rcaliman-apple commented Sep 1, 2022

7d37933

Web Inspector: Assertion when removing event listener in CSSPropertyNameCompletions.js
https://bugs.webkit.org/show_bug.cgi?id=240606

Reviewed by Patrick Angle.

When reloading the page with Web Inspector open:
- the map of `WI.DOMNodeStyles` is cleared in `WI.CSSManager._mainResourceDidChange()`;
- the selected node is re-selected and a new `WI.DOMNode` is created for it;
- the event `WI.DOMManager.Event.InspectedNodeChanged` is dispatched with the data payload member
`lastInspectedNode` pointing to this new instance;

When requesting the `WI.cssManager.stylesForNode(event.data.lastInspectedNode)`, a new instance
of `WI.DOMNodeStyles` is created and returned. This new instance did not have an event listener attached for
`WI.DOMNodeStyles.Event.NeedsRefresh`. Therefore, when attempting to remove the event listener, the assertion is hit.

This patch makes `CSSPropertyNameCompletions` hold its own reference to the inspected node's `WI.DOMNodeStyles`
and remove to reliably remove the event listener.

* Source/WebInspectorUI/UserInterface/Models/CSSPropertyNameCompletions.js:
(WI.CSSPropertyNameCompletions.prototype._handleInspectedNodeChanged):

Canonical link: https://commits.webkit.org/254072@main

808b938

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac   πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
  πŸ›  ios-sim   πŸ›  mac-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ›  mac-AS-debug   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ api-mac   πŸ§ͺ api-gtk
  πŸ›  tv   πŸ§ͺ mac-wk1
  πŸ›  tv-sim   πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
  πŸ›  watch-sim   πŸ§ͺ mac-wk2-stress

@rcaliman-apple rcaliman-apple self-assigned this Sep 1, 2022
@rcaliman-apple rcaliman-apple added Web Inspector Bugs related to the WebKit Web Inspector. WebKit Nightly Build labels Sep 1, 2022
@patrickangle
Copy link
Contributor

Nit: in commit message: a new **instace** of WI.DOMNodeStyles

@rcaliman-apple rcaliman-apple force-pushed the eng/Web-Inspector-Assertion-when-removing-event-listener-in-CSSPropertyNameCompletions-js branch from a6dc0d1 to 808b938 Compare September 1, 2022 20:59
@rcaliman-apple rcaliman-apple added the merge-queue Applied to send a pull request to merge-queue label Sep 1, 2022
…ameCompletions.js

https://bugs.webkit.org/show_bug.cgi?id=240606

Reviewed by Patrick Angle.

When reloading the page with Web Inspector open:
- the map of `WI.DOMNodeStyles` is cleared in `WI.CSSManager._mainResourceDidChange()`;
- the selected node is re-selected and a new `WI.DOMNode` is created for it;
- the event `WI.DOMManager.Event.InspectedNodeChanged` is dispatched with the data payload member
`lastInspectedNode` pointing to this new instance;

When requesting the `WI.cssManager.stylesForNode(event.data.lastInspectedNode)`, a new instance
of `WI.DOMNodeStyles` is created and returned. This new instance did not have an event listener attached for
`WI.DOMNodeStyles.Event.NeedsRefresh`. Therefore, when attempting to remove the event listener, the assertion is hit.

This patch makes `CSSPropertyNameCompletions` hold its own reference to the inspected node's `WI.DOMNodeStyles`
and remove to reliably remove the event listener.

* Source/WebInspectorUI/UserInterface/Models/CSSPropertyNameCompletions.js:
(WI.CSSPropertyNameCompletions.prototype._handleInspectedNodeChanged):

Canonical link: https://commits.webkit.org/254072@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Web-Inspector-Assertion-when-removing-event-listener-in-CSSPropertyNameCompletions-js branch from 808b938 to 7d37933 Compare September 1, 2022 22:07
@webkit-commit-queue
Copy link
Collaborator

Committed 254072@main (7d37933): https://commits.webkit.org/254072@main

Reviewed commits have been landed. Closing PR #3920 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 7d37933 into WebKit:main Sep 1, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Sep 1, 2022
@rcaliman-apple rcaliman-apple deleted the eng/Web-Inspector-Assertion-when-removing-event-listener-in-CSSPropertyNameCompletions-js branch September 7, 2022 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Web Inspector Bugs related to the WebKit Web Inspector.
Projects
None yet
4 participants