Blockstream / Blockstream/green_android

Camera resource preemption in multi-window mode causing app crash

Open
#242 1 comment 0 reactions 1 assignee Claimed by @ardier16 View on GitHub
bug status: awaiting-reporter
Dominant language
Kotlin
Stars
268
Forks
106
PR merge metrics
No merged PRs in 30d

Description

### Description

The application crashes in multi-window mode when the camera resource is preempted or accessed by another application, causing freezing, crashing, or abnormal behavior.

### Steps to reproduce

1. Run the target application in full-screen mode and activate the camera functionality.
2. Launch another application that also requires access to the camera resource in floating window mode and enable its camera functionality.
3. Refocus on the target application by clicking on its interface area to return the operational focus to the application.
4. Observe the operational state and behavioral performance of the target application.

### Expected behaviour

The application should be able to regain access to the camera resource after refocusing, without freezing, crashing, or exiting unexpectedly.

### Actual behaviour

After regaining focus, the application interface freezes, the application crashes, and it needs to be restarted to recover.

### Additional info

It might be beneficial to consider implementing logic within the onWindowFocusChanged callback method to handle scenarios where the application regains focus. This could include reinitializing or reallocating the camera stream, which may help mitigate resource conflicts and enhance the application's stability. Below is an example of how such logic could be structured in pseudocode:

```
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);

if (hasFocus) {
try {
camera = Camera.open();
camera.startPreview();
} catch (Exception e) {
Log.e("CameraHandler", "Error handling camera: " + e.getMessage());
}
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.