feat: Add console
logging support for Frame Processors (#297)
* Try to log to console via runOnJS * Call `console.log` * Create custom `VisionCameraScheduler` * Fix scheduler call * Call with this * Fix console setting * Move J---- to `java-bindings` * c++ style * Android: 1/2 Create custom Scheduler * Android: 2/2 Use custom Scheduler * Don't use `runOnJS`, use `__callAsync` directly
This commit is contained in:
@@ -26,11 +26,11 @@ class FrameProcessorRuntimeManager(context: ReactApplicationContext) {
|
||||
@DoNotStrip
|
||||
private var mHybridData: HybridData
|
||||
private var mContext: WeakReference<ReactApplicationContext>
|
||||
private var mScheduler: Scheduler
|
||||
private var mScheduler: VisionCameraScheduler
|
||||
|
||||
init {
|
||||
val holder = context.catalystInstance.jsCallInvokerHolder as CallInvokerHolderImpl
|
||||
mScheduler = Scheduler(context)
|
||||
mScheduler = VisionCameraScheduler()
|
||||
mContext = WeakReference(context)
|
||||
mHybridData = initHybrid(context.javaScriptContextHolder.get(), holder, mScheduler)
|
||||
initializeRuntime()
|
||||
@@ -43,7 +43,6 @@ class FrameProcessorRuntimeManager(context: ReactApplicationContext) {
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
mScheduler.deactivate()
|
||||
mHybridData.resetNative()
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ class FrameProcessorRuntimeManager(context: ReactApplicationContext) {
|
||||
private external fun initHybrid(
|
||||
jsContext: Long,
|
||||
jsCallInvokerHolder: CallInvokerHolderImpl,
|
||||
scheduler: Scheduler
|
||||
scheduler: VisionCameraScheduler
|
||||
): HybridData
|
||||
private external fun initializeRuntime()
|
||||
private external fun registerPlugin(plugin: FrameProcessorPlugin)
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package com.mrousavy.camera.frameprocessor;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.mrousavy.camera.CameraViewModule;
|
||||
|
||||
@SuppressWarnings("JavaJniMissingFunction") // using fbjni here
|
||||
public class VisionCameraScheduler {
|
||||
@DoNotStrip
|
||||
private final HybridData mHybridData;
|
||||
|
||||
public VisionCameraScheduler() {
|
||||
mHybridData = initHybrid();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
mHybridData.resetNative();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
private native HybridData initHybrid();
|
||||
private native void triggerUI();
|
||||
|
||||
@DoNotStrip
|
||||
private void scheduleTrigger() {
|
||||
CameraViewModule.Companion.getFrameProcessorThread().submit(this::triggerUI);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user