Closed Bug 2087663 Opened 1 month ago Closed 26 days ago

Crash in [@ java.util.concurrent.RejectedExecutionException: at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java)]

Categories

(Firefox for Android :: Search, defect, P1)

All
Android
defect

Tracking

()

RESOLVED FIXED
161 Branch
Tracking Status
firefox159 --- unaffected
firefox160 + verified
firefox161 + verified

People

(Reporter: clouseau-bot, Assigned: harrisono, NeedInfo)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: crash, regression, Whiteboard: [fxdroid][android-activation-trust])

Crash Data

Attachments

(3 external files)

Crash report: https://crash-stats.mozilla.org/report/index/7254bca2-571b-45bc-bf2b-248620261030

Top 10 frames:

0  java.util.concurrent.ThreadPoolExecutor$AbortPolicy  rejectedExecution
1  java.util.concurrent.ThreadPoolExecutor  reject
2  java.util.concurrent.ThreadPoolExecutor  execute
3  java.util.concurrent.Executors$DelegatedExecutorService  execute
4  android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy  onClosed
5  android.hardware.camera2.impl.CameraCaptureSessionImpl  close
6  mozilla.components.feature.qr.QrFragment$createCameraPreviewSession$1$1$stateCallback$1  onConfigured  mobile/android/android-components/components/feature/qr/src/main/java/mozilla/components/feature/qr/QrFragment.kt
7  android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy  lambda$onConfigured$0
8  android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$soW0qC12Osypoky6AfL3P2-TeDw  run
9  java.util.concurrent.ThreadPoolExecutor  runWorker

There is 1 crash in beta 160.0b3 with buildid 20261030090331.

This signature is not new: its first report anywhere is in build 20120210031150 (2012-02-10), 5376 days before the build above. (A 364-day crash-stats search only reaches 2024-10-11, because Socorro's search index keeps about six months — which is why the signature looks much newer there.)

Timing check: this signature was already being reported in build 20241011205646, 747 days before the changeset named below landed, so that changeset cannot be what INTRODUCED this SIGNATURE. It may still be relevant, and it may still be the cause of the crash in this particular report — an old signature can acquire a new cause, and a rare crash can be made frequent by a change that did not create it — but the signature's own history is not evidence that it is.

Clouseau analysis (automated). The mechanism below fits the evidence but is not proven end-to-end:

QrFragment's capture-session onConfigured calls CameraCaptureSession.close() while its backgroundExecutor is shut down, so the framework's onClosed dispatch is rejected and the RejectedExecutionException goes uncaught.

  1. On API >= 28, createCaptureSessionCompat passes backgroundExecutor (a newSingleThreadExecutor, default AbortPolicy) to SessionConfiguration, so onConfigured runs on it and onClosed is delivered through it.
  2. Pausing the fragment runs stopServices(): closeCamera() nulls cameraDevice, then stopExecutorService() calls shutdownNow() and interrupts the worker.
  3. Changeset 6c25e94d94c5 replaced the old if (null == cameraDevice) return in onConfigured with onSessionConfigured(), which calls session.close() when tryAcquire is interrupted or fails, and when cameraDevice == null || session.device != cameraDevice.
  4. That close() makes CameraCaptureSessionImpl post onClosed to the terminated executor, which throws RejectedExecutionException, and nothing in onSessionConfigured catches it.

The stack shows exactly onConfigured -> CameraCaptureSessionImpl.close -> SessionStateCallbackProxy.onClosed -> DelegatedExecutorService.execute -> AbortPolicy, on a ThreadPoolExecutor worker. The parent revision's onConfigured had no close() call, so the old code cannot produce this stack. The report does not show which of the two new close() calls fired or the exact timing against shutdownNow(); the interrupt path is the likeliest. Look first at the two session.close() calls in onSessionConfigured: catch RejectedExecutionException there as closeCamera() already does.

The crash is on Android 28 (API 28), where the SessionConfiguration path with backgroundExecutor is used, and frames #9-#11 show the callback running on a ThreadPoolExecutor worker, which matches that executor. The candidate landed on beta on 2026-10-28, and build 20261030090331 (rev fb7bcc275b0b) contains onSessionConfigured. The signature dates from 2012 only because it matches any rejected executor task; this changeset added a new QR-scanner route into it and did not create the signature. 0% of this signature's reports carry hardware-error flags.

Suspected regressor: 6c25e94d94c5 (gh) (bug 2086228) by Harrison Oglesby.

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):

  • pass edge0 — At build rev fb7bcc275b0b, createCaptureSessionCompat passes backgroundExecutor as Executor (from Executors.newSingleThreadExecutor()) to SessionConfiguration on API >= P. Frames #4 and #7 show both callbacks proxied through that executor.
  • pass hunk0 — The parent (fd84f54ea693) onConfigured never calls close(), so the frame #6 -> #5 (onConfigured -> CameraCaptureSessionImpl.close) stack can only come from the code the candidate added. The candidate is the newest change to the file at the build rev.
  • pass mechanism — Neither new close() is wrapped, and handleCaptureException would rethrow RejectedExecutionException anyway. closeCamera() already catches this exception for its own close, which shows the risk is known. The exact interleaving with shutdownNow() is not observed in the report. R8 inlining of the single-caller onSessionConfigured into onConfigured fits the missing frame but cannot be confirmed from a JVM stack.

Harrison Oglesby, can you have a look please?

Filed automatically by Clouseau, which analyses beta and Developer Edition 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.

:harrisono, since you are the author of the regressor, bug 2086228, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(hoglesby)

On API 28+, the capture session callbacks run on backgroundExecutor. If the fragment stops while onConfigured is still pending, stopServices() shuts the executor down (and interrupts the worker). onSessionConfigured() then calls session.close(), and the framework tries to post onClosed to the terminated executor. That throws an uncaught RejectedExecutionException.

Close the unused session through a helper that catches and logs RejectedExecutionException, the same way closeCamera() already does.

The bug is marked as tracked for firefox160 (beta) and tracked for firefox161 (nightly). However, the bug still isn't assigned.

:skhan, could you please find an assignee for this tracked bug? Given that it is a regression and we know the cause, we could also simply backout the regressor. If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(skhan)

I'll look into this.

Flags: needinfo?(hoglesby)
Assignee: nobody → hoglesby
Status: NEW → ASSIGNED
Whiteboard: [fxdroid][android-activation-trust]
Severity: -- → S3
Priority: -- → P1

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: A fix for the crash regression in the QR code scanner screen. Some devices might still crash even after the last patch I requested an uplift for.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: no
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Low risk, adds an exception try-catch to eliminate a crash.
  • String changes made/needed?: None
  • Is Android affected?: yes
Attachment #9672669 - Flags: approval-mozilla-beta?
Pushed by hoglesby@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/006efdbf7c0e https://hg.mozilla.org/integration/autoland/rev/4366640f690a Catch RejectedExecutionException when closing an unused capture session in QrFragment. r=android-reviewers,joberhauser
Status: ASSIGNED → RESOLVED
Closed: 26 days ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch
Attachment #9672669 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triage-done-c161/b160]

Verified on Firefox 160.0 across the following devices:

  • Google Pixel 8 (Android 16)
  • Samsung Galaxy Tab S3 (Android 9)
  • Honor Magic V2 (Android 14)

No crashes encountered.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: