Closed Bug 2086771 Opened 27 days ago Closed 18 days ago

Confirmation hint can close early when shown again while it is still opening

Categories

(Firefox :: Tabbed Browser, defect, P3)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: dgraham, Assigned: dgraham)

References

Details

(Whiteboard: [fidefe-tabgrps])

Attachments

(1 external file)

While working on bug 2081441 I found that if ConfirmationHint.show() gets called a second time while a hint is still opening, it ends up starting two auto-hide timers, and only one of them gets cleaned up when the hint closes. The leftover one fires about 3 seconds later and closes whatever hint is open at that point, so a later hint can disappear almost right after it shows up.

It looks like show() handles the hint being closed or fully open, but not the in-between "showing" state.

Steps to reproduce:

This is a timing issue (the second hint has to be triggered within a fraction of a second of the first), so it's hard to hit by hand. The easiest way to see it is with the test from bug 2081441, so it would likely be verified with further automated tests:

  1. In browser/components/tabbrowser/test/browser/tabs/browser_tab_group_menu.js, remove the wait for the hint to open inside the loop in test_saveAndCloseGroup_confirmationHintCappedAtThree. That test saves and closes several tab groups back to back, so the second hint gets triggered while the first is still opening.
  2. Run ./mach test browser/components/tabbrowser/test/browser/tabs/browser_tab_group_menu.js --verify --headless.

Expected: each hint stays open until the test closes it

Actual: the hint tests intermittently fail with "Confirmation hint panel is visible - false == true", because the leftover timer from the earlier test closes the hint

This should theoretically also happen if the second show call happens while the panel is in hiding state.

The Bugbug bot thinks this bug should belong to the 'Firefox::Tabbed Browser' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Tabbed Browser

The cause is in ConfirmationHint.show() in browser.js. That file is owned by Firefox :: General; bug 2062137, which added the state == "open" branch, was filed there. The tab group save hint in tabgroup.mjs is only the caller that triggers it.

"showing": openPopup is refused unless the popup is closed or invisible (nsXULPopupManager.cpp). Each call still adds another {once} popupshown listener (startAutoHideTimer, #5050-5066). When the event fires, both listeners call setTimeout. The first ID is overwritten, and _reset() on popuphidden only clears the second, so the leaked timer later calls hidePopup(true) on whatever hint is showing then.

"hiding" (comment 1): the show is refused here too, so the new hint is dropped. Both popuphidden listeners run _reset() and strip the new hint's attributes. The new popupshown listener is left registered, so it fires again on the next show and leaks a timer the same way.

Proposed fix, all in browser.js:

  1. In startAutoHideTimer, clearTimeout(this._timerID) before setting a new one.
  2. Store the pending popupshown handler on the object (e.g. this._onShown) and remove the previous one before adding a new one. Clear the reference when it fires and when the popup hides, so only the latest call's handler (and its duration) can start a timer. Do the same for the popuphidden handler.
  3. If this._panel.state == "hiding", wait for popuphidden {once} and then re-run show() with the same arguments, rather than setting content now. panelUI.js (selectAndMarkItem) already handles a re-show during "hiding" this way.

Tests: browser_confirmationHint.js only covers a second show() after popupshown (the "open" state). Add two cases:

  • A second show() before popupshown: after the hint hides, a later hint must stay open past the first hint's timeout. Sinon fake timers would avoid a real 3s wait.
  • A show() during "hiding": the hint must reopen with the new message.

With the fix in, the bug 2081441 loop in browser_tab_group_menu.js (test_saveAndCloseGroup_confirmationHintCappedAtThree) should no longer need to wait for the hint inside the loop.

Suggested severity: S4. A transient confirmation hint closes early or is dropped only when two hints are triggered within a fraction of a second, with no loss of state or function.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

If show() was called while a hint was still opening, each call added its own popupshown listener, so two auto-hide timers started. Only one of them could be cleared, and the other one later closed whatever hint was open at the time. show() now only keeps the latest call's listeners.

If show() was called while a hint was hiding, the new hint was silently dropped, because openPopup does nothing in that state. It now waits for popuphidden and then shows the hint.

Attachment #9671837 - Attachment description: Bug 2086771 - Stop confirmation hints closing early or being dropped when shown again while opening or hiding. r?florian → Bug 2086771 - Stop confirmation hints closing early or being dropped when shown again while opening or hiding. r?#firefox-desktop-core-reviewers
Pushed by dgraham@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/42f28cdc9bd6 https://hg.mozilla.org/integration/autoland/rev/0cc44f2c3c86 Stop confirmation hints closing early or being dropped when shown again while opening or hiding. r=firefox-desktop-core-reviewers ,dao
Status: ASSIGNED → RESOLVED
Closed: 18 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: