Closed Bug 2054232 Opened 1 month ago Closed 1 month ago

[Google Lens] Firefox crashes after I toggle into/out-of Google Lens camera view a few times (Crash in [@ java.lang.IllegalArgumentException: at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java)] )

Categories

(Firefox for Android :: Search, defect)

All
Android
defect

Tracking

()

VERIFIED FIXED
155 Branch
Tracking Status
firefox154 --- verified
firefox155 --- verified

People

(Reporter: dholbert, Assigned: harrisono)

References

(Blocks 1 open bug)

Details

(Keywords: crash, crashreportid, Whiteboard: [fxdroid][group3])

Crash Data

Attachments

(2 files)

Steps to reproduce

  1. Open a new tab,
  2. Focus the URL bar.
  3. Tap the Google Lens logo at the right side.
  4. Tap "x" (top left) to go back to your new-tab.
  5. Repeat steps 3 and 4 several times.

Expected behavior

No crash.

Actual behavior

Firefox crashes, e.g. bp-c1160369-683f-43ee-b70b-161430260710

Device information

  • Firefox version: 154.0a1 Nightly 2026-07-09
  • Android device model: Pixel 10 Pro XL
  • Android OS version: 17

Any additional information?

I haven't yet been able to repro on my Pixel 6a. But this reproduces very reliably on my Pixel 10 Pro XL -- I've crashed 3-4 times in the past half hour or so (first on accident, then on purpose after I realized how to trigger it).

Summary: [Google Lens] Firefox crashes after I toggle into/out-of Google Lens camera view a few times → [Google Lens] Firefox crashes after I toggle into/out-of Google Lens camera view a few times (Crash in [@ java.lang.IllegalArgumentException: at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java)] )
Crash Signature: [@ java.lang.IllegalArgumentException: at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java)]
Keywords: crash, crashreportid

This crashes in 153 beta, too (if I enable Google Lens there via the secret setting):
bp-fd0cac5a-0bdc-4966-aa80-4c29d0260711

Here's the Java Stack Trace from my crash in comment 0:

java.lang.IllegalArgumentException: CaptureRequest contains unconfigured Input/Output Surface!
	at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java:791)
	at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1727)
	at android.hardware.camera2.impl.CameraDeviceImpl.setRepeatingRequest(CameraDeviceImpl.java:1857)
	at android.hardware.camera2.impl.CameraCaptureSessionImpl.setRepeatingRequest(CameraCaptureSessionImpl.java:328)
	at org.mozilla.fenix.components.lens.LensCameraFragment$createCameraPreviewSession$1$1$sessionStateCallback$1.onConfigured(LensCameraFragment.kt:53)
	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0(CallbackProxies.java:53)
	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.$r8$lambda$_n4IjoKfaLTNPhb0V-jusXTXwVU(CallbackProxies.java:0)
	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy$$ExternalSyntheticLambda5.run(D8$$SyntheticClass:0)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:1572)

Googling for the exception (java.lang.IllegalArgumentException: CaptureRequest contains unconfigured Input/Output Surface!) turns up some maybe-useful AI-Overview advice, and some instances where other folks have tripped this same suggestion. But I don't know the relevant Android/Kotlin APIs well enough to know whether they're applicable.

(In reply to Daniel Holbert [:dholbert] from comment #0)

I haven't yet been able to repro on my Pixel 6a. But this reproduces very reliably on my Pixel 10 Pro XL -- I've crashed 3-4 times in the past half hour or so (first on accident, then on purpose after I realized how to trigger it).

Ah, one maybe-important difference between these devices is that my Pixel 6a (apparently-unaffected) was running Android 16, whereas my Pixel 10 Pro XL (affected) is running Android 17.

I'm now downloading Android 17 for my Pixel 6a; I'll report back about whether that happens to help the bug repro there...

OK, after upgrading to Android 17, I managed to repro the crash on my Pixel 6a. Sample crash report:
bp-d0a0b578-1732-407a-8367-5f3270260711

It sometimes takes ~45seconds of cycling the final step of the STR (google lens, back, google lens, back) in order to trigger the crash there, though. So I'm not actually sure whether upgrading to Android 17 was the relevant factor, or whether it was just that it requires more thorough/aggressive application of the STR on that device, and I hadn't done that until after I upgraded. (e.g. maybe there's a race condition that the Pixel 6a happens to come out on the good side of, most of the time). Not sure.

Also worth noting, my Firefox Nightly profile on the Pixel 6a is basically "fresh" (I reinstall/clear-data-for Nightly all the time there and haven't tweaked any settings since the most recent time I did that). So I don't think this requires any special configuration in Firefox itself in order to trigger.

I was curious if this also affected the preexisting QR-code-only flow, and it seems the answer is no (i.e. the old QR code flow is unaffected by this -- this is specific to the Lens flow).

I tested that old flow flow by turning off Lens in Firefox Nightly settings|search|"enable google lens search-->off". And with that configuration, repeatedly cycling the STR here, I have not been able to reproduce any crash (with the QR-code-only flow). I tried this on both of the devices that I've mentioned here, in latest Nightly.

Assignee: nobody → hoglesby
Status: NEW → ASSIGNED
Whiteboard: [fxdroid][group3]
Attachment #9609338 - Attachment description: Bug 2054232 - Fix race condition with camera preview session in LensCameraActivity.kt → Bug 2054232 - Fix race condition with camera preview session in LensCameraFragment
Pushed by hoglesby@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8636df9f28c9 https://hg.mozilla.org/integration/autoland/rev/15256842fa9a Fix race condition with camera preview session in LensCameraFragment r=android-reviewers,petru
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 155 Branch

The patch landed in nightly and beta is affected.
:harrisono, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(hoglesby)

yes, I'll uplift this to beta 154

Flags: needinfo?(hoglesby)

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Users can experience a full app crash if they rapidly open and close the Google Lens integration camera screen. This needs to be addressed before we have wide adoption in 154.
  • 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: Removal of race condition for the camera session in the LensCameraActivity, low risk of regressions.
  • String changes made/needed?: none.
  • Is Android affected?: yes
Attachment #9615208 - Flags: approval-mozilla-beta?
Attachment #9615208 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

I was only able to reproduce the crash on a Pixel 9 Pro (Android 17) device.
Verified as fixed on the latest Firefox for Android nightly 155.0a1 from 7/23 with the above-mentioned device.
Setting the qe-verify+ label to verify the fix in Beta 154 as well.

Flags: qe-verify+

Verified as fixed on the Firefox for Android Beta 154.0b2 using the Pixel 9 Pro (Android 17) device.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: