[Crash] UninitializedPropertyAccessException in CameraCaptureHandler when attaching photo via camera
Summary
Thunderbird crashes when adding an attachment to a message using the camera. The crash occurs when MessageCompose receives the successful camera activity result after the application process has been recreated.
The issue is reproducible on the main branch and was found during the target SDK 36 migration.
Environment
- Product:
lineage_gta4xl - Model:
SM_P615 - Device:
gta4xl - Android version: Android 16
- Application ID:
net.thunderbird.android.debug - WebView version:
145.0.7632.109
Steps to reproduce
- Open the message composer or edit an existing draft.
- Select the option to add an attachment.
- Choose the camera as the attachment source.
- Capture and accept an image.
- Return to Thunderbird.
Actual behaviour
The application crashes while resuming MessageCompose and processing the camera result:
java.lang.RuntimeException: Unable to resume activity
{net.thunderbird.android.debug/com.fsck.k9.activity.MessageCompose}
Caused by: java.lang.RuntimeException:
Failure delivering result ResultInfo{who=null, request=6, result=-1, data=null}
Caused by: kotlin.UninitializedPropertyAccessException:
Image Uri not initialized
at app.k9mail.core.android.common.camera.CameraCaptureHandler.getCapturedImageUri(
CameraCaptureHandler.kt:30
)
at com.fsck.k9.activity.MessageCompose.onActivityResult(
MessageCompose.java:984
)
The log shows that the original application process is terminated before the camera result is handled. Android then starts a new process, restores MessageCompose with the EDIT_DRAFT intent, and delivers a successful activity result with data=null. The recreated CameraCaptureHandler no longer has its captured-image URI initialized, so getCapturedImageUri() throws UninitializedPropertyAccessException.
Expected behaviour
The captured image should be attached to the message after returning from the camera, including when the activity or application process has been recreated. A missing or unrestored camera output URI should be handled without crashing.
Suspected cause
The camera output URI is held only in the in-memory state of CameraCaptureHandler and is not restored after process recreation. MessageCompose.onActivityResult() assumes that the URI is always initialized when it receives a successful camera result.
We need to make CameraCaptureHandler survive process death.
Hi, I’d like to work on this. I plan to persist and restore the pending camera output URI through MessageCompose’s saved instance state, add focused restoration coverage, and ensure missing state doesn’t crash. Could you assign this issue to me?