【问题标题】:Null Pointer Dereference in switchEffectRawNative with Flutter Plugin for Android and DeepAR带有适用于 Android 和 DeepAR 的 Flutter 插件的 switchEffectRawNative 中的空指针取消引用
【发布时间】:2021-10-01 21:28:36
【问题描述】:

我将 DeepAR (https://developer.deepar.ai/) 与 Flutter 结合使用。我正在为 Android 创建一个 Flutter 插件。我使用 JetPack 支持库 CameraX 来访问相机。该库提供了一个名为“ImageAnalyse”(https://developer.android.com/training/camerax/analyze)的用例。我尝试将其与 DeepAR 结合起来。我想通过相机使用 DeepAR 显示的蒙版作为资产在 App Bundle 中。当我调用“switchEffect”时,应用程序崩溃了。

Flutter 插件

Flutter 插件的架构遵循 Flutter 文档中的建议。

class ExamplePlugin : FlutterPlugin, ActivityAware {
    private var flutterPluginBinding: FlutterPluginBinding? = null
    private var activityPluginBinding: ActivityPluginBinding? = null
    // overrides are implemented but left out for simplicity
}
class PluginViewFactory(
    private val flutterPluginBinding: FlutterPlugin.FlutterPluginBinding, private val activityPluginBinding: ActivityPluginBinding
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {

    override fun create(context: Context?, id: Int, args: Any?): PlatformView {
        return PluginView(flutterPluginBinding, activityPluginBinding, context, id, args)
    }
}
class PluginView(
    flutterPluginBinding: FlutterPluginBinding,
    activityPluginBinding: ActivityPluginBinding,
    private val context: Context?,
    id: Int,
    args: Any?
) : PlatformView, MethodChannel.MethodCallHandler, PluginRegistry.RequestPermissionsResultListener,
    AREventListener {
    private val activity = activityPluginBinding.activity
    // I left out some code for simplicity

创建 ProcessCameraProvider

    private fun startCamera() {
        val cameraProviderFuture = ProcessCameraProvider.getInstance(activity)
        cameraProviderFuture.addListener({
            cameraProvider = cameraProviderFuture.get()
            bindPreviewAndAnalysis(cameraProvider)
        }, ContextCompat.getMainExecutor(activity))
    }

绑定图片预览和图片分析用例

    private fun bindPreviewAndAnalysis(cameraProvider: ProcessCameraProvider?) {
        // Preview
        val imagePreview = Preview.Builder()
            .build()
            .also {
                it.setSurfaceProvider(previewView.surfaceProvider)
            }

        // Analysis
        val cameraPreset = CameraResolutionPreset.P1280x720
        val width: Int
        val height: Int
        val orientation: Int = getScreenOrientation()
        if (orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            width = cameraPreset.width
            height = cameraPreset.height
        } else {
            width = cameraPreset.height
            height = cameraPreset.width
        }
        arrayOfNulls<ByteBuffer>(NUMBER_OF_BUFFERS).also { buffers = it }
        for (i in 0 until NUMBER_OF_BUFFERS) {
            buffers[i] = ByteBuffer.allocateDirect(width * height * 3)
            buffers[i]?.order(ByteOrder.nativeOrder())
            buffers[i]?.position(0)
        }
        val imageAnalysis = ImageAnalysis.Builder().setTargetResolution(Size(width, height))
            .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build()
        cameraExecutor?.let {
            imageAnalysis.setAnalyzer(
                it,
                { image ->
                    val byteData: ByteArray
                    val yBuffer: ByteBuffer = image.planes[0].buffer
                    val uBuffer: ByteBuffer = image.planes[1].buffer
                    val vBuffer: ByteBuffer = image.planes[2].buffer
                    val ySize: Int = yBuffer.remaining()
                    val uSize: Int = uBuffer.remaining()
                    val vSize: Int = vBuffer.remaining()
                    byteData = ByteArray(ySize + uSize + vSize)

                    //U and V are swapped
                    yBuffer.get(byteData, 0, ySize)
                    vBuffer.get(byteData, ySize, vSize)
                    uBuffer.get(byteData, ySize + vSize, uSize)
                    buffers[currentBuffer]?.put(byteData)
                    buffers[currentBuffer]?.position(0)
                    if (deepAR != null) {
                        deepAR?.receiveFrame(
                            buffers[currentBuffer],
                            image.width,
                            image.height,
                            image.imageInfo.rotationDegrees,
                            cameraSelector == CameraSelector.DEFAULT_FRONT_CAMERA,
                            DeepARImageFormat.YUV_420_888,
                            image.planes[1].pixelStride
                        )
                    }
                    currentBuffer = (currentBuffer + 1) % NUMBER_OF_BUFFERS
                    image.close()
                })
        }

        try {
            cameraProvider?.unbindAll()

            cameraSelector?.let {
                cameraProvider?.bindToLifecycle(activity as LifecycleOwner,
                    it, imagePreview, imageAnalysis)
            }
        } catch (e: Exception) {
            Log.e(TAG, "Use case binding failed", e)
        }
    }

使用 DeepAR switchEffect

    private fun changeMask(mask: String) {
        try {
            val loader = FlutterInjector.instance().flutterLoader()
            val path = loader.getLookupKeyForAsset("assets/masks/$mask", "my_plugin_name")
            val maskFd: AssetFileDescriptor = activity.assets.openFd(path)
            deepAR?.switchEffect("masks", maskFd.createInputStream())
        } catch (exc: Exception) {
            Log.e(TAG, "Could not change mask", exc)
        }
    }

错误

当调用“switchEffect”时,应用程序崩溃并出现以下错误:

F/libc    (20852): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 20852 (.example.app), pid 20852 (.example.app)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/walleye/walleye:11/RP1A.201005.004.A1/6934943:user/release-keys'
Revision: 'MP1'
ABI: 'arm64'
Timestamp: 2021-07-25 13:59:29+0200
pid: 20852, tid: 20852, name: .example.app  >>> com.example.app <<<
uid: 10194
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000007129de3570  x1  0000007129de3570  x2  0000007139e3b210  x3  0000007119769984
    x4  0000007ff61c6788  x5  0000000000000000  x6  0000000000000001  x7  6ced3fea237c8a73
    x8  0000000000000000  x9  6ced3fea237c8a73  x10 0000000000430000  x11 0000000029de3576
    x12 000000005375645e  x13 0000007ff61c68a0  x14 0000000000000002  x15 00000000ebad6a89
    x16 00000073acaaa7f8  x17 00000073aabc5bd0  x18 00000073af972000  x19 0000007139e3b210
    x20 0000007ff61c68b0  x21 00000071d9d95c70  x22 0000000000000001  x23 0000007ff61c68b4
    x24 0000000000000000  x25 00000073af273000  x26 0000000000000069  x27 0000007119d77000
    x28 0000007ff61c68c0  x29 0000007ff61c6890
    lr  000000707f88e504  sp  0000007ff61c6850  pc  000000707f88e514  pst 0000000060000000
backtrace:
      #00 pc 000000000004a514  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libnative-lib.so (Java_ai_deepar_ar_DeepAR_switchEffectRawNative+268) (BuildId: 342abf6bf48a1e62b230a5496cbaeecab0b6c701)
      #01 pc 000000000013ced4  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: d0f321775158ed00df284edfabf672b6)
      #02 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #03 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #04 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #05 pc 0000000000313288  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+696) (BuildId: d0f321775158ed00df284edfabf672b6)
      #06 pc 000000000068b144  /apex/com.android.art/lib64/libart.so (MterpInvokeDirectRange+436) (BuildId: d0f321775158ed00df284edfabf672b6)
      #07 pc 000000000012dc14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct_range+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #08 pc 0000000000162a36  [anon:dalvik-classes.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk] (ai.deepar.ar.DeepAR.switchEffect+70)
      #09 pc 0000000000685960  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: d0f321775158ed00df284edfabf672b6)
      #10 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #11 pc 000000000001a49c  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.changeMask+296)
      #12 pc 0000000000687fe8  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+1248) (BuildId: d0f321775158ed00df284edfabf672b6)
      #13 pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #14 pc 000000000001a53a  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.changeMaskNative+42)
      #15 pc 0000000000687fe8  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+1248) (BuildId: d0f321775158ed00df284edfabf672b6)
      #16 pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #17 pc 000000000001a962  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.onMethodCall+154)
      #18 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #19 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #20 pc 000000000036ef32  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage+34)
      #21 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #22 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #23 pc 0000000000364daa  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart+114)
      #24 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #25 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #26 pc 0000000000363a64  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage+8)
      #27 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #28 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #29 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #30 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #31 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #32 pc 000000000055c6f4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+468) (BuildId: d0f321775158ed00df284edfabf672b6)
      #33 pc 000000000055c894  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) (BuildId: d0f321775158ed00df284edfabf672b6)
      #34 pc 00000000004197f8  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+656) (BuildId: d0f321775158ed00df284edfabf672b6)
      #35 pc 000000000037deac  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+2532) (BuildId: d0f321775158ed00df284edfabf672b6)
      #36 pc 000000000036bc50  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+72) (BuildId: d0f321775158ed00df284edfabf672b6)
      #37 pc 000000000132663c  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #38 pc 0000000001326578  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #39 pc 0000000001322408  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #40 pc 000000000138428c  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #41 pc 0000000001342568  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #42 pc 00000000013476f8  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #43 pc 000000000001a064  /system/lib64/libutils.so (android::Looper::pollInner(int)+916) (BuildId: b81fad2b6b7b7f85c6217d2cb80c9e61)
      #44 pc 0000000000019c68  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: b81fad2b6b7b7f85c6217d2cb80c9e61)
      #45 pc 00000000001120f4  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #46 pc 000000000020fadc  /system/framework/arm64/boot-framework.oat (art_jni_trampoline+140) (BuildId: da25c976c2d1d3af123868772655a0779f8f6a48)
      #47 pc 000000000200b6cc  /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.MessageQueue.next+204)
      #48 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #49 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #50 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #51 pc 0000000000312228  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: d0f321775158ed00df284edfabf672b6)
      #52 pc 00000000006856c0  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: d0f321775158ed00df284edfabf672b6)
      #53 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #54 pc 0000000000396970  /system/framework/framework.jar (offset 0x92b000) (android.os.Looper.loop+156)
      #55 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #56 pc 0000000000311840  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #57 pc 0000000000312b9c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, true>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1772) (BuildId: d0f321775158ed00df284edfabf672b6)
      #58 pc 0000000000178658  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<true, false>(art::interpreter::SwitchImplContext*)+58656) (BuildId: d0f321775158ed00df284edfabf672b6)
      #59 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: d0f321775158ed00df284edfabf672b6)
      #60 pc 00000000001a1698  /system/framework/framework.jar (android.app.ActivityThread.main)
      #61 pc 00000000003095d8  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+528) (BuildId: d0f321775158ed00df284edfabf672b6)
      #62 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #63 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #64 pc 00000000001337e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: d0f321775158ed00df284edfabf672b6)
      #65 pc 00000000001a9804  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: d0f321775158ed00df284edfabf672b6)
      #66 pc 000000000055ce14  /apex/com.android.art/lib64/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1364) (BuildId: d0f321775158ed00df284edfabf672b6)
      #67 pc 00000000004dba28  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+48) (BuildId: d0f321775158ed00df284edfabf672b6)
      #68 pc 00000000000896f4  /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+180) (BuildId: 13577ce71153c228ecf0eb73fc39f45010d487f8)
      #69 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #70 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #71 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #72 pc 0000000000312228  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: d0f321775158ed00df284edfabf672b6)
      #73 pc 00000000006856c0  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: d0f321775158ed00df284edfabf672b6)
      #74 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #75 pc 000000000044930a  /system/framework/framework.jar (offset 0x125d000) (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+22)
      #76 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #77 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #78 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #79 pc 0000000000897668  /system/framework/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2280) (BuildId: da25c976c2d1d3af123868772655a0779f8f6a48)
      #80 pc 00000000001337e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: d0f321775158ed00df284edfabf672b6)
      #81 pc 00000000001a9804  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: d0f321775158ed00df284edfabf672b6)
      #82 pc 000000000055b830  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+448) (BuildId: d0f321775158ed00df284edfabf672b6)
      #83 pc 000000000055bcf4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) (BuildId: d0f321775158ed00df284edfabf672b6)
      #84 pc 000000000043ecbc  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+652) (BuildId: d0f321775158ed00df284edfabf672b6)
      #85 pc 000000000009948c  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #86 pc 00000000000a0a0c  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+844) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #87 pc 0000000000003570  /system/bin/app_process64 (main+1320) (BuildId: d4686d3f8282764488eb9ca7cc518583)
      #88 pc 00000000000495b4  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: c78cdff5b820a550771130d6bde95081)
Lost connection to device.

环境

  • Kotlin 1.5.20
  • 颤振 2.2.3
  • DeepAR 2.4.1
  • CameraX 1.1.0-alpha07 / 1.0.0-alpha27

补充说明

我在 Android 模拟器(API 级别 30)和真正的 Android 设备(Pixel 2、Android 11)上运行带有 Flutter 插件的 Flutter 应用时看到此错误。我在调试模式和发布模式下运行 Flutter 应用程序时看到此错误。

非常欢迎任何帮助或任何建议。我对 Flutter 和 Android 开发不熟悉,所以我很可能错过了一些重要方面。

我也在 DeepAR 的 GitHub 仓库中发布了这个问题:https://github.com/DeepARSDK/quickstart-android-java/issues/30

【问题讨论】:

    标签: android flutter kotlin flutter-plugin


    【解决方案1】:

    只是想让你知道,我现在选择了不同的方法。最后,我将“switchEffect”与 FileInputStream 一起使用,效果很好:

        private fun getMaskAsFileInputStream(mask: String): FileInputStream? {
            return try {
                val loader = FlutterInjector.instance().flutterLoader()
                val path = loader.getLookupKeyForAsset("assets/masks/$mask", "my_plugin_name")
                val maskFd: AssetFileDescriptor = activity.assets.openFd(path)
                if (maskFd.length > 0) {
                    maskFd.createInputStream()
                } else {
                    Log.w(TAG, "Mask asset at $path is empty")
                    null
                }
            } catch (exc: Exception) {
                Log.e(TAG, "Could not get mask as file input stream", exc)
                null
            }
        }
    
        private fun changeMask(mask: String) {
            try {
                deepAR?.switchEffect("masks", getMaskAsFileInputStream(mask))
            } catch (exc: Exception) {
                Log.e(TAG, "Could not change mask", exc)
            }
        }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-20
      • 2021-09-18
      • 2011-03-23
      • 1970-01-01
      • 2016-05-16
      • 2022-01-14
      相关资源
      最近更新 更多