I have implemented React Native bridging using a manager and module class in Ktolin. I am trying to access the native Android camera from React Native.
While trying to access the Android camera, I am facing a timeout issue.
*E/Camera2CameraImpl: Unable to configure camera 0, timeout!
*
E/unknown:ReactContextBaseJavaModule: Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by DeviceInfo
at com.facebook.react.bridge.ReactContextBaseJavaModule.getReactApplicationContextIfActiveOrWarn(ReactContextBaseJavaModule.java:66)
at com.facebook.react.modules.deviceinfo.DeviceInfoModule.invalidate(DeviceInfoModule.java:114)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:110)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:108)
at com.facebook.react.bridge.CatalystInstanceImpl$1.run(CatalystInstanceImpl.java:368)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:1012)
I will attach the manager class and context conversion to the fragmented activity.
// RNCameramanager.kt
package com.barcode.BarcodeScanner
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
class ScannerBarcodeManager() : SimpleViewManager<ScannerBarcodeView>() {
override fun getName() = "SFScannerBarcodeManager"
override fun createViewInstance(reactThemContext: ThemedReactContext): ScannerBarcodeView {
return ScannerBarcodeView(reactThemContext)
}
}
RNCameraView.kt
private val activity : FragmentActivity
get()= getActivity(context)!!
private fun getActivity(activity: Context): FragmentActivity? {
var context: Context? = activity
while (context is ContextWrapper) {
if (context is FragmentActivity) {
Log.i("","inside")
return context
}
context = context.baseContext
}
return null
}
I am Expecting to access the camera from the Native. I would greatly appreciate any suggestions or guidance on how to resolve this issue. Thank you in advance for your help.