mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-26 09:20:23 +00:00
Initialize CameraX on a background thread.
We saw a situation where CameraX initialization could lock up when trying to obtain system resource. We already fallback to the Camera1Fragment when CameraX isn't initialized, so it should be safe to do this initialization on its own thread.
This commit is contained in:
@@ -386,11 +386,13 @@ public class ApplicationContext extends MultiDexApplication implements DefaultLi
|
|||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
private void initializeCameraX() {
|
private void initializeCameraX() {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
CameraX.init(this, Camera2AppConfig.create(this));
|
CameraX.init(this, Camera2AppConfig.create(this));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.w(TAG, "Failed to initialize CameraX.");
|
Log.w(TAG, "Failed to initialize CameraX.");
|
||||||
}
|
}
|
||||||
|
}, "signal-camerax-initialization").start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user