Camera resource preemption in multi-window mode causing app crash #2769
Labels
bug
Something isn't working
help wanted
Open to community contribution at any time
p3
Priority 3
sensor-camera
Issue Description
In multi-window mode, when an application is running in full-screen mode and using the camera, if another application is opened in floating window mode and takes control of the camera resource, a focus switch may cause the original application’s camera resource to fail to recover properly. When the user switches back to the original application, the camera resource should be restored for use. However, in practice, the application interface may freeze or crash, and the application needs to be restarted to recover normal functionality.
Expected Behavior
In multi-window mode, applications using the camera resource should be able to smoothly transfer camera resource control during focus changes:
Suggested Solution
It is recommended to add appropriate logic in the onWindowFocusChanged method to handle the camera resource allocation during focus changes. This method is triggered when the Activity's window focus state changes, including when the application starts for the first time or when returning from another Activity. By checking the hasFocus parameter, the application can determine whether it has regained focus, and if so, it should attempt to reinitialize or request access to the camera resource. In multi-window mode, adding this logic can help better coordinate the use of camera resources, thereby improving the application’s stability and user experience in multi-tasking scenarios. Below is an example of pseudocode:
By incorporating this logic during focus changes, it can effectively reduce camera resource conflicts in multi-window mode and enhance the application's stability and reliability.
The text was updated successfully, but these errors were encountered: