Closed Bug 2088553 Opened 24 days ago Closed 23 days ago

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

Categories

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

defect

Tracking

()

RESOLVED FIXED
161 Branch
Tracking Status
firefox-esr153 --- unaffected
firefox159 --- unaffected
firefox160 --- unaffected
firefox161 --- 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/de5b19d9-a95c-4839-ad34-154800261103

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::OnTouch(unsigned long long, long long)  widget/windows/nsWindow.cpp:6931
3  xul.dll  nsWindow::ProcessMessageInternal(unsigned int, unsigned long long&, long long&, ...  widget/windows/nsWindow.cpp:5950
4  xul.dll  nsWindow::WindowProcInternal(HWND__*, unsigned int, unsigned long long, long lon...  widget/windows/nsWindow.cpp:4776
5  xul.dll  nsWindow::WindowProc(HWND__*, unsigned int, unsigned long long, long long)  widget/windows/nsWindow.cpp:4733
6  user32.dll  UserCallWinProcCheckWow(_ACTIVATION_CONTEXT*, int64_t (*)(tagWND*, unsigned int,...
7  user32.dll  SendMessageWorker(tagWND*, unsigned int, uint64_t, int64_t, int)
8  user32.dll  SendMessageInternal(HWND__*, unsigned int, uint64_t, int64_t, int)
9  user32.dll  SendMessageW

There is 1 crash in nightly 161 with buildid 20261103080110.

Crash-stats has no report of this signature on any earlier build, and Socorro's all-time signature index has no entry for it yet — as far as we can tell it is new with this build.

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 non-consumed MULTITOUCH_MOVE arrives while the touch-swipe phase is Idle.

  1. eea5a3340120 (bug 2085126) added the touchscreen swipe-to-nav state machine and turned it on by default in Nightly via widget.swipe.touchscreen.enabled = @IS_NIGHTLY_BUILD@.
  2. In MayStartSwipeForTouchInput, the MULTITOUCH_MOVE case checks for Idle only with MOZ_ASSERT, and the only early return is for Rejected, so release builds continue to GetDelta in Idle.
  3. previousTouchPoint is Some only after Start(); Reset() sets it back to Nothing and the phase to Idle.
  4. The state can probably become Idle while a finger is still down. On Windows, nsWindow::OnTouch puts DOWN/MOVE contacts in one START/MOVE event and UP contacts in a separate END. When one finger lifts and another goes down in the same frame, TouchCounter::Update counts only the new finger on START and subtracts the lifted one on END. The count reaches 0, and the END path added in 64937b3aab8d calls Reset().
  5. The remaining finger's next move then reaches GetDelta with previousTouchPoint == Nothing and trips MOZ_RELEASE_ASSERT(isSome()).

The crash reason MOZ_RELEASE_ASSERT(isSome()), the inlined Maybe::operator* / TouchSwipeState::GetDelta at widget/nsIWidget.cpp:1345, and the nsWindow::OnTouch caller match this path. The build is the first Nightly to contain the series. Step 4 is an inferred trigger: a two-finger touchpad START converted to a pan gesture, so the widget never records it, would also leave the phase Idle.

Blame at the build revision shows the crashing lines (widget/nsIWidget.cpp 1345-1346) and the Rejected-only early return came from eea5a3340120. The count-based Reset() came from 64937b3aab8d, and the EventsAreControllingSwipe check just above came from 11e385cb5285. All are bug 2085126, landed 2026-11-02, and appear in build 20261103080110, which is this crash's build and the signature's first report. The pref that enables the path is on by default in Nightly in the same patch. Neither the hardware flags nor the Nimbus recipes point anywhere else.

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

Impact

The parent process crashes, so the whole browser closes. Debug builds would first fire the MOZ_ASSERT that the phase is Pending or Rejected in the MULTITOUCH_MOVE case; release builds skip it and hit the release assert in Maybe::operator*.

Possible fixes

  • In MayStartSwipeForTouchInput, possibly treat MULTITOUCH_MOVE in Phase::Idle (or any state where previousTouchPoint is Nothing) as rejected or ignored, instead of relying on the debug-only MOZ_ASSERT.
  • Possibly make TouchSwipeState's finger counting match Windows WM_TOUCH framing, where the START/MOVE event leaves out contacts lifted in the same frame, so Reset() does not run while a finger is still down.
  • Possibly make the swipe state ignore touch sequences whose START was never seen by DispatchTouchInput, such as two-finger touchpad STARTs converted to a pan gesture.

How to confirm

Add a test to browser_test_touchscreen_swipe_gesture_with_multitouch.js that, through nsIWidget::DispatchTouchInput, sends finger A START, then a frame with A UP and B DOWN (START [B] followed by END [A]), then a horizontal MOVE [B] outside the slop. A release build is expected to hit MOZ_RELEASE_ASSERT(isSome()) in GetDelta; a debug build should fail the Phase::Pending || Phase::Rejected assert first.

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 mechanism — That the phase was Idle at the crash follows from the build source (the only states with previousTouchPoint == Nothing are Idle/after Reset, and Rejected returns early). The exact touch sequence that led to Idle with a finger down (a mixed UP/DOWN frame miscounted by TouchCounter, or a two-finger touchpad START converted to a pan gesture) is inferred and not observed in this report.
  • unverifiable hunk2 — Same series. It adds the count-based Reset() on END, a plausible route to Idle with a finger still down. Even without it, eea5a3340120's unconditional Reset() on END already allowed the same state.
  • unverifiable other — Different bug (2086760), score 0. Nothing ties it to the touch-swipe state machine. Not diffed.
  • pass hunk0 — Blame at the build revision attributes the crashing lines 1345-1346 (GetDelta call), the Rejected-only early return at 1326, and the debug-only phase assert at 1318 to eea5a3340120. The code did not exist before this series.
  • pass other — Adds the mSwipeTracker->EventsAreControllingSwipe() reject just before the crashing line. It cannot produce an Idle phase. It is the same series, so a co-candidate, not a separate cause.

: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

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

:canalun, since you are the author of the regressor, bug 2085126, could you take a look?

For more information, please visit BugBot documentation.

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

Crash stack:

MOZ_RELEASE_ASSERT(isSome())
mozilla::Maybe<ScreenIntPoint>::operator*()
nsIWidget::TouchSwipeState::GetDelta()
nsIWidget::MayStartSwipeForTouchInput()
nsIWidget::DispatchTouchInput()
nsWindow::OnTouch()

Likely cause:

I couldn't reproduce this crash, but the following is a likely cause
considering the stack trace.

nsWindow::OnTouch splits one WM_TOUCH into two inputs and dispatches
them in this order:
(https://searchfox.org/firefox-main/rev/2b71df5bf2e07525d1129be46e0ee02ec70d34d8/widget/windows/nsWindow.cpp#6929-6936)

  1. MULTITOUCH_START (or MOVE) with the DOWN and MOVE contacts
  2. MULTITOUCH_END with the UP contacts

Therefore, if the user lifts finger A up and puts finger B down
in the same WM_TOUCH (i.e., almost at the same time), the inputs
are split and delivered in the below order:

(Note MULTITOUCH_START[B] comes first.)

Input                Count  Phase    previousTouchPoint
(A is on the screen) 1      Pending  A
MULTITOUCH_START[B]  1      Pending  B (Start() is called again)
MULTITOUCH_END[A]    0      Idle     Nothing (Reset() is called)
MULTITOUCH_MOVE[B]   0      Idle     Nothing
                                     -> GetDelta() crashes

The count becomes 0 while B is still down, so the phase goes back
to Idle. The next move of B then reaches GetDelta() with no previous
point.

Fix:

  • When the phase is Idle, accept only MULTITOUCH_START. Other
    inputs mean the count doesn't reflect the actual finger
    arrangement, so skip them.
  • When the phase is not Idle, at least one finger is already
    down. So a MULTITOUCH_START with only one finger should not
    happen. Skip it as well.

Note that only swipe handling is skipped. APZ and content still
receive these inputs.

Test:

This patch doesn't have a test. The crash needs one WM_TOUCH that
has an UP contact and a DOWN contact together. Our test helpers
can't make it.
(e.g. nsWindow::InjectTouchPoint injects one contact per
InjectTouchInput() call.)

Assignee: nobody → i.am.kanaru.sato
Status: NEW → ASSIGNED
Flags: needinfo?(i.am.kanaru.sato)
See Also: → 2089005
See Also: → 2089067
Pushed by i.am.kanaru.sato@gmail.com: https://github.com/mozilla-firefox/firefox/commit/71e20e018eb2 https://hg.mozilla.org/integration/autoland/rev/9263828808c4 Fix a crash in touchscreen swipe when one finger lifts and another touches down at once. r=hiro
Status: ASSIGNED → RESOLVED
Closed: 23 days ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch
QA Whiteboard: [qa-triage-done-c162/b161]
Duplicate of this bug: 2089067
See Also: → 1443710
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: