Commits
cristianoccazinsp authored and Sibelius Seraphini committed 87774dd3700
feat(android): Android ui thread (#2560)
* Move heavy work to a dedicated background thread. Improves camera initial loading and resumes from background.
Details:
- Use a HandlerThread to delegate heavy tasks to background. The thread is managed by the view, and passed down to the implementation in case it also needs to use it. The view will fire start calls and other possibly heavy operations in this thread to avoid ANRs. Some code sent to this thread:
- start calls: start is extremely heavy and will cause ANRs on some devices, especially when coming back from background
- Camera1: some preset changes fire a stop/start sequence. These will now happen in the background thread
- take picture and start recording (from view class) will also start in this thread
- Add some extra null checks
- View was not properly cleaning up itself on destroy (host destroy event was never fired)
* catch possible errors when starting camera preview. This might still randomly fail on some devices for some reason.
* delay capture in progress until we have resumed/paused preview.
* do not crash the app if set texture setup failed
* more synchronized checks to prevent crashes due to concurrent camera updates
* remove unused imports