Closed Bug 2086228 Opened 27 days ago Closed 27 days ago

Crash in [@ java.lang.IllegalArgumentException: at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java)]

Categories

(Firefox for Android :: Search, defect)

Unspecified
Android
defect

Tracking

()

VERIFIED FIXED
161 Branch
Tracking Status
firefox159 + wontfix
firefox160 + verified
firefox161 + verified

People

(Reporter: aryx, Assigned: harrisono)

References

Details

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

Crash Data

Attachments

(3 external files, 2 obsolete files)

See bug 2054232 for previous instance.

Crashes on Android 17, increased volume since Firefox for Android 154.

Crash report: https://crash-stats.mozilla.org/report/index/fa2a3c82-9639-4b0b-96c1-99f0e0261027

Top 10 frames:

0  android.hardware.camera2.CaptureRequest  convertSurfaceToStreamId  CaptureRequest.java:791
1  android.hardware.camera2.impl.CameraDeviceImpl  submitCaptureRequest  CameraDeviceImpl.java:1743
2  android.hardware.camera2.impl.CameraDeviceImpl  setRepeatingRequest  CameraDeviceImpl.java:1873
3  android.hardware.camera2.impl.CameraCaptureSessionImpl  setRepeatingRequest  CameraCaptureSessionImpl.java:348
4  mozilla.components.feature.qr.QrFragment$createCameraPreviewSession$1$1$state...  onConfigured  QrFragment.kt:68
5  android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy  lambda$onConfigured$0  CallbackProxies.java:53
6  android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy  $r8$lambda$_n4IjoKfaLTNPhb0V-jusXTXwVU  CallbackProxies.java:0
7  android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy$$Exte...  run  D8$$SyntheticClass:0
8  java.util.concurrent.ThreadPoolExecutor  runWorker  ThreadPoolExecutor.java:1100
9  java.util.concurrent.ThreadPoolExecutor$Worker  run  ThreadPoolExecutor.java:624
Flags: needinfo?(hoglesby)

[Tracking Requested - why for this release]: crash volume

Same race as bug 2054232 (LensCameraFragment), in the android-components QrFragment: closeCamera() on the main thread can release the output surfaces while CameraCaptureSession.StateCallback.onConfigured() runs on the background executor, so setRepeatingRequest() throws IllegalArgumentException ("CaptureRequest contains unconfigured Input/Output Surface!") and crashes.

  • Move onConfigured logic into onSessionConfigured(). Gate the camera-alive check and the session assignment on cameraOpenCloseLock. If the camera is already closed, close the new session instead of leaking it.
  • Catch IllegalArgumentException from setRepeatingRequest for the remaining window where surfaces can be released.
  • Build the preview CaptureRequest before creating the session, not in the callback. Drop the previewRequestBuilder/previewRequest fields, and set surface to null after it is released in closeCamera().
Assignee: nobody → hoglesby
Status: NEW → ASSIGNED
Flags: needinfo?(hoglesby)
Whiteboard: [fxdroid][android-activation-trust]

Port the LensCameraFragment fix from bug 2054232: onConfigured runs on the
background executor while closeCamera() can release the output surfaces on the
main thread, making setRepeatingRequest throw IllegalArgumentException.

Pushed by hoglesby@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c04b224419fe https://hg.mozilla.org/integration/autoland/rev/46d3abb592bc Fix race condition with camera preview session in QrFragment. r=android-reviewers,Roger
Status: ASSIGNED → RESOLVED
Closed: 27 days ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch

The patch landed in nightly and beta is affected.

:harrisono, please make an uplift decision for beta:

  • For beta, nominate the patch for beta uplift approval if the fix should be included in this release, or set status-firefox160 to wontfix if the fix can wait for the next release.

Uplift requests can be submitted from Lando: D337274, D337341.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(hoglesby)

requesting an uplift now

Flags: needinfo?(hoglesby)

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Crash occurring in the Google Lens/QR code camera activity. rising fast.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Closes a session issue with the cameras, more risky to not have this patch than to add it.
  • String changes made/needed?: none.
  • Is Android affected?: yes
Attachment #9670769 - Flags: approval-mozilla-beta?

Port the LensCameraFragment fix from bug 2054232: onConfigured runs on the
background executor while closeCamera() can release the output surfaces on the
main thread, making setRepeatingRequest throw IllegalArgumentException.

Original Revision: https://phabricator.services.mozilla.com/D337341

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Rising crash in camera screens for Google Lens/QR code scanner. small fix to fix a race condition.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Small race condition fix, more risky to not uplift this patch than to uplift.
  • String changes made/needed?: none
  • Is Android affected?: yes
Attachment #9670772 - Flags: approval-mozilla-beta?

Port the LensCameraFragment fix from bug 2054232: onConfigured runs on the
background executor while closeCamera() can release the output surfaces on the
main thread, making setRepeatingRequest throw IllegalArgumentException.

Original Revision: https://phabricator.services.mozilla.com/D337341

firefox-release Uplift Approval Request

  • User impact if declined/Reason for urgency: Rising crash in camera screens for Google Lens/QR code scanner. small fix to fix a race condition.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Small race condition fix, more risky to not uplift this patch than to uplift.
  • String changes made/needed?: none
  • Is Android affected?: yes
Attachment #9670773 - Flags: approval-mozilla-release?

Port the LensCameraFragment fix from bug 2054232: onConfigured runs on the
background executor while closeCamera() can release the output surfaces on the
main thread, making setRepeatingRequest throw IllegalArgumentException.

Original Revision: https://phabricator.services.mozilla.com/D337341

Attachment #9670772 - Attachment is obsolete: true
Attachment #9670772 - Flags: approval-mozilla-beta?
Attachment #9670769 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Regressions: 2087663

Looks like the new crash introduced by this change is as bad or worse as the one it was trying to fix.

Attachment #9670773 - Attachment is obsolete: true
Attachment #9670773 - Flags: approval-mozilla-release?

Verified on the latest Nightly from 01/11 and the latest Beta 160.0b3 with Pixel 7 Pro (Android 17). No crash enncountered.

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

Attachment

General

Created:
Updated:
Size: