Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera resource preemption in multi-window mode causing app crash #242

Open
Huimilia opened this issue Jan 4, 2025 · 0 comments
Open

Camera resource preemption in multi-window mode causing app crash #242

Huimilia opened this issue Jan 4, 2025 · 0 comments

Comments

@Huimilia
Copy link

Huimilia commented Jan 4, 2025

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());
        }
    } 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant