Closed Bug 2089067 Opened 24 days ago Closed 16 days ago

Crash in [@ mozilla::Maybe<T>::operator* | nsIWidget::TouchSwipeState::GetDelta]

Categories

(Core :: Panning and Zooming, defect, P2)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2088553
Tracking Status
firefox-esr153 --- unaffected
firefox159 --- unaffected
firefox160 --- unaffected
firefox161 --- fixed
firefox162 --- fixed

People

(Reporter: clouseau-bot, Assigned: canalun)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: crash, regression)

Crash Data

Attachments

(1 external file)

Crash report: https://crash-stats.mozilla.org/report/index/4f015887-8c76-4596-bc7b-54e100261104

MOZ_CRASH Reason:

MOZ_RELEASE_ASSERT(isSome())

Top 10 frames:

0  xul.dll  nsIWidget::MayStartSwipeForTouchInput(mozilla::MultiTouchInput const&, mozilla::...  widget/nsIWidget.cpp:1345
1  xul.dll  nsIWidget::DispatchTouchInput(mozilla::MultiTouchInput&)  widget/nsIWidget.cpp:1507
2  xul.dll  nsWindow::OnTouchPointerEvents(unsigned int, unsigned int, unsigned long long, l...  widget/windows/nsWindow.cpp:8464
3  xul.dll  nsWindow::OnPointerEvents(unsigned int, unsigned long long, long long)  widget/windows/nsWindow.cpp:8227
4  xul.dll  nsWindow::ProcessMessageInternal(unsigned int, unsigned long long&, long long&, ...  widget/windows/nsWindow.cpp:5425
5  xul.dll  nsWindow::WindowProcInternal(HWND__*, unsigned int, unsigned long long, long lon...  widget/windows/nsWindow.cpp:4776
6  xul.dll  nsWindow::WindowProc(HWND__*, unsigned int, unsigned long long, long long)  widget/windows/nsWindow.cpp:4733
7  user32.dll  UserCallWinProcCheckWow(_ACTIVATION_CONTEXT*, int64_t (*)(tagWND*, unsigned int,...
8  user32.dll  DispatchMessageWorker
9  xul.dll  NS_ProcessNextEvent(nsIThread*, bool)  xpcom/threads/nsThreadUtils.cpp:471

There are 5 crashes (from 5 installations) in nightly 161 starting with buildid 20261103080110.

This signature is new: its first report anywhere is in build 20261103080110 (2026-11-03), the build above.

Clouseau analysis (automated, 72% worth investigating — a calibrated estimate that this is worth someone's time, not that the changeset below caused it). The mechanism below fits the evidence but is not proven end-to-end:

nsIWidget::MayStartSwipeForTouchInput dereferences an empty TouchSwipeState::previousTouchPoint in GetDelta() when a MULTITOUCH_MOVE arrives while the swipe phase is Idle; here that is probably because touches were undercounted on the WM_POINTER touch path.

  1. eea5a3340120 added touchscreen swipe-to-nav, enabled on Nightly through widget.swipe.touchscreen.enabled; for MULTITOUCH_MOVE it only debug-asserts the phase and then calls GetDelta() unconditionally.
  2. 64937b3aab8d resets TouchSwipeState to Idle whenever touchCounter reaches 0 on MULTITOUCH_END, and Reset() clears previousTouchPoint.
  3. In this crash the input came from nsWindow::OnTouchPointerEvents, which probably fills a WM_POINTERUP's MULTITOUCH_END with every contact in the pointer frame (GetPointerFrameTouchInfo), while TouchCounter::Update subtracts all of them as if they were released.
  4. So lifting one of two fingers can probably drop the count to 0, and the state becomes Idle while a finger is still down.
  5. The remaining finger's next WM_POINTERUPDATE becomes a MULTITOUCH_MOVE; in Idle it passes the Rejected early-return and reaches GetDelta(), where *previousTouchPoint hits MOZ_RELEASE_ASSERT(isSome()).

The crash reason MOZ_RELEASE_ASSERT(isSome()), the inlined Maybe::operator* in GetDelta at nsIWidget.cpp:1345, and the OnPointerEvents → OnTouchPointerEvents frames fit this chain. The source shows directly that only Idle can reach this line with Nothing. How Idle was reached (steps 3–4) is inferred from the code and depends on Windows pointer-frame behaviour that I did not verify; the WM_TOUCH split described in bug 2088553 comment 3 is another way to reach Idle, but not the one this stack took.

The signature was first seen in build 20261103080110, the first build after the bug 2085126 series landed on 2026-11-02. Blame puts the crashing GetDelta line and the MOVE fall-through in eea5a3340120, and the count-based Reset() in 64937b3aab8d. The feature pref added by eea5a3340120 is on by default in Nightly, so the code runs for every Nightly touchscreen user. None of the 5 reports carries a bit-flip or Raptor Lake flag. Bug 2088553 is open on the same signature, but its proposed cause is WM_TOUCH, while this report went through the WM_POINTER path.

Suspected regressor: eea5a3340120 (gh) (bug 2085126) by :canalun.

Impact

The parent process crashes, so the whole browser closes.

Possible fixes

  • In MayStartSwipeForTouchInput, treat a MULTITOUCH_MOVE (or END) arriving in Phase::Idle as reject or ignore instead of falling through to GetDelta(), for example if (mTouchSwipeState.phase != TouchSwipeState::Phase::Pending) return; after the switch.
  • On the WM_POINTER touch path, build the MULTITOUCH_END with only the contacts flagged POINTER_FLAG_UP, so TouchCounter does not undercount (this probably also affects APZ's own TouchCounter).
  • Make TouchSwipeState::GetDelta return a fallible result (e.g. Maybe<ScreenIntPoint>) so a missing start point rejects the swipe instead of crashing.

How to confirm

With dom.w3c_pointer_events.dispatch_by_pointer_messages.touch=true and widget.swipe.touchscreen.enabled=true on a Windows touchscreen, put down finger A, put down finger B, lift B, then move A. Log touchCounter.GetActiveTouchCount() and mTouches.Length() for each MULTITOUCH_END in DispatchTouchInput to confirm the count drops to 0 while A is down. A gtest or browser test that calls DispatchTouchInput with an END listing both touches, followed by a MOVE, should hit the assert.

Code references:

What the automated skeptic pass checked

In its own words (a pass means the check succeeded, which is not always support for the conclusion):

  • unverifiable trigger — That GetPointerFrameTouchInfo returns still-down contacts on WM_POINTERUP is Windows API behaviour that the tools cannot check. The WM_TOUCH split from bug 2088553 comment 3 cannot be what happened here, because this stack goes through OnTouchPointerEvents. That path runs only when dom.w3c_pointer_events.dispatch_by_pointer_messages.touch is on, and it defaults to false.
  • pass mechanism — Self-checked; the skeptic subagent was not run. In the build source, only the Idle phase can reach GetDelta from MayStartSwipeForTouchInput with previousTouchPoint == Nothing. The fall-through and the GetDelta call blame to eea5a3340120, which also added widget.swipe.touchscreen.enabled defaulting to @IS_NIGHTLY_BUILD@. The signature is first seen in this build.
  • pass noise-check — 11e385cb5285 only adds an early rejectSwipe() before GetDelta when a touchpad swipe is active. That cannot produce Idle with Nothing; it is part of the same series but not the cause.

Filed as a new bug rather than a comment on bug 2088553: it is open on this signature but appears to track a different defect.

  • Bug 2088553: The bug's crash and its diagnosed cause and fix in comment 3 are on the WM_TOUCH path (nsWindow::OnTouch). The draft's crash takes the WM_POINTER path (OnPointerEvents/OnTouchPointerEvents) with a different proposed trigger, even though...
    Please duplicate if that is wrong.

:canalun, can you have a look please?

Filed automatically by Clouseau with an LLM, from a submitted crash report: not an independent Mozilla discovery

Filed automatically by Clouseau, which analyses nightly crashes with an LLM. Nothing above was written or checked by a human. Please close it as INVALID if it is wrong — that is useful feedback, not a nuisance.

This is not an independent Mozilla discovery: the crash is known here only because somebody submitted the crash report linked at the top. If this duplicates an existing report, please resolve THIS bug as the duplicate and leave the credit with the earlier reporter.

Flags: needinfo?(i.am.kanaru.sato)

Set release status flags based on info from the regressing bug 2085126

Considering the fact that the same assertion in GetDelta() fails and it might be caused by TOUCH_MOVE in Idle phase, this will be fixed by the patch for bug 2088553.
Once I confirm the suspected behavior of nsWindow::OnTouchPointerEvents (i.e., probably fills a WM_POINTERUP's MULTITOUCH_END with every contact in the pointer frame), I will file a bug and add a reference to that on the codebase.

Flags: needinfo?(i.am.kanaru.sato)
Severity: -- → S3
Priority: -- → P2
See Also: → 2088553

Although it's a crash in parent process, both dom.w3c_pointer_events.dispatch_by_pointer_messages.touch and widget.swipe.touchscreen.enabled have to be switched to true in order to produce the bug. So for now I've marked this bug as S3.

Set release status flags based on info from the regressing bug 2085126

I confirmed the below.

  • This bug is NOT reproduced on the latest Nightly (162.0a1 2026-11-10) thanks to the fix of bug 2088553
  • The described behavior of OnTouchPointerEvents was reproduced on my Windows laptop.

I filed a bug, bug 2091573, for the bug of OnTouchPointerEvents.

See Also: → 2091573
Status: NEW → RESOLVED
Closed: 16 days ago
Duplicate of bug: 2088553
Resolution: --- → DUPLICATE

Bug 2091573, a bug of Windows widget, causes the situation in which
MULTITOUCH_END makes the touch count 0 and resets the phase even
though the finger is still on the screen.

The fix for bug 2089005, a Windows widget bug causing the same
situation, prevents a crash caused by bug 2091573 as well. So, this
patch adds a mention in the code comment as future reference.

No test is added, because the MULTITOUCH_END including several
contacts is necessary to trigger bug 2091573 and such input can't
be reproduced on mochitest.
(With native injection, nsWindow::InjectTouchPoint passes only a
single contact to InjectTouchInput. With
apz.test.fails_with_native_injection enabled, the synthesized
MULTITOUCH_END contains only the lifted touch.)

Assignee: nobody → i.am.kanaru.sato

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

See Also: → 1443710
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: