Vonage-Community / sample-video-flutter-app

Apache License 2.0
5 stars 1 forks source link

E/BufferQueueProducer: dequeueBuffer: BufferQueue has been abandoned #6

Open jttuboi opened 1 year ago

jttuboi commented 1 year ago

Hello, my project has a problem mentioned in the title above and I am not able to solve it. I don't have much knowledge of kotlin and I have no idea what is going on to generate this error. In the research I did, the only important thing I discovered is that it has to do with not finding the place where it should be open to receive the video. I tried some changes to synchronize the time to leave and enter each user in the room and I still couldn't solve it. I know it's not exactly an opentok error, but I'm not finding a solution anywhere, so I'm asking for help here.

Just below is the simplified project based on this one, which makes it possible to reproduce the error. In my project is something similar, I will explain.

https://github.com/jttuboi/flutter_training_other_projects/tree/main/app40/sample-video-flutter-app-main

First, to reproduce the error in this simplified project, I ran the project and there is only 1 button (one to one). When you click on it, you enter the screen with the video of the cell phone user showing in a small square. When adding a subscriber, it appears behind a window that takes up almost the entire screen. After that, I clicked back, waited a bit, and clicked again. Note: do not disconnect the subscriber from the room. The error starts to generate a little after returning to the screen that should show the same as before. Use flutter 3.3.8 and opentok 2.24.0.

In my project, it's a little different, but the same error happens with dequeueBuffer. The 2 are already in the room, but the subscriber leaves, so when he returns, the error occurs. You can see that the error happens when entering the page and showing the videos again with the "new" users.

If you just want to see the generated log, it's just below.

Log ``` Launching lib/main.dart on sdk gphone64 arm64 in debug mode... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. I/flutter_samples(18048): Late-enabling -Xcheck:jni W/flutter_samples(18048): type=1400 audit(0.0:234): avc: denied { read } for name="max_map_count" dev="proc" ino=368000 scontext=u:r:untrusted_app:s0:c158,c256,c512,c768 tcontext=u:object_r:proc_max_map_count:s0 tclass=file permissive=0 app=com.vonage.tutorial.opentok.opentok_flutter_samples W/flutter_samples(18048): Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (unsupported,test-api, reflection, allowed) W/flutter_samples(18048): Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (unsupported, reflection, allowed) W/flutter_samples(18048): Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (unsupported, reflection, allowed) W/flutter_samples(18048): Accessing hidden method Landroid/util/LongArray;->get(I)J (unsupported, reflection, allowed) Connecting to VM Service at ws://127.0.0.1:53564/NRDsZNVBWkk=/ws E/SurfaceSyncer(18048): Failed to find sync for id=0 W/Parcel (18048): Expecting binder but got null! V/[com.opentok.android](18048): ***** OpenTok Android SDK | Version/Revision: android-2.24.0/7316208e3bf83c855acb8a31765dff7b2b6a2b57 | Library built on: Oct 31 2022 | Copyright 2022 Vonage | https://www.vonage.com/legal/communications-apis/terms-of-use/ D/ (18048): OneToOneVideo.session.onConnected(SESSION_TOKEN) I/CameraManagerGlobal(18048): Connecting to camera service I/PlatformViewsController(18048): Hosting view in a virtual display for platform view: 0 W/PlatformViewsController(18048): Unexpected platform view context for view ID 0; some functionality may not work correctly. When constructing a platform view in the factory, ensure that the view returned from PlatformViewFactory#create returns the provided context from getContext(). If you are unable to associate the view with that context, consider using Hybrid Composition instead. D/HostConnection(18048): createUnique: call D/HostConnection(18048): HostConnection::get() New Host Connection established 0xb400007797e20b10, tid 18131 D/HostConnection(18048): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 D/[DefaultVideoRenderer(native)](18048): VideoRenderOpenGles20: id 0 D/[DefaultVideoRenderer(native)](18048): Setup: width 303, height 495 D/[DefaultVideoRenderer(native)](18048): Setup: number of textures 16, size 16384 W/Parcel (18048): Expecting binder but got null! D/ (18048): OneToOneVideo.publisher.onStreamCreated(EA54931C-0238-491A-B16B-2459BD63E901, EA54931C-0238-491A-B16B-2459BD63E901) D/ (18048): OneToOneVideo.session.onStreamReceived(SESSION_TOKEN, 5743400b-3315-469d-ad56-e96ddaf3fe04) D/HostConnection(18048): createUnique: call D/HostConnection(18048): HostConnection::get() New Host Connection established 0xb400007797e253d0, tid 18183 D/HostConnection(18048): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 D/[DefaultVideoRenderer(native)](18048): VideoRenderOpenGles20: id 0 D/[DefaultVideoRenderer(native)](18048): Setup: width 1080, height 1107 D/[DefaultVideoRenderer(native)](18048): Setup: number of textures 16, size 16384 W/AudioManager(18048): Use of stream types is deprecated for operations other than volume control W/AudioManager(18048): See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case W/AudioTrack(18048): Use of stream types is deprecated for operations other than volume control W/AudioTrack(18048): See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case D/ (18048): OneToOneVideo.subscriber.onConnected(5743400b-3315-469d-ad56-e96ddaf3fe04) D/ (18048): OneToOneVideo.session.onConnected(SESSION_TOKEN) D/ (18048): OneToOneVideo.session.onStreamReceived(SESSION_TOKEN, 5743400b-3315-469d-ad56-e96ddaf3fe04) D/ (18048): OneToOneVideo.session.onStreamReceived(SESSION_TOKEN, EA54931C-0238-491A-B16B-2459BD63E901) D/HostConnection(18048): createUnique: call D/HostConnection(18048): HostConnection::get() New Host Connection established 0xb400007797e23750, tid 18223 D/HostConnection(18048): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 E/CameraCaptureSession(18048): Session 0: Exception while stopping repeating: E/CameraCaptureSession(18048): android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): checkPidStatus:2085: The camera device has been disconnected E/CameraCaptureSession(18048): at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1390) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:99) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1341) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:579) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:790) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:267) E/CameraCaptureSession(18048): at android.os.Handler.handleCallback(Handler.java:942) E/CameraCaptureSession(18048): at android.os.Handler.dispatchMessage(Handler.java:99) E/CameraCaptureSession(18048): at android.os.Looper.loopOnce(Looper.java:201) E/CameraCaptureSession(18048): at android.os.Looper.loop(Looper.java:288) E/CameraCaptureSession(18048): at android.app.ActivityThread.main(ActivityThread.java:7898) E/CameraCaptureSession(18048): at java.lang.reflect.Method.invoke(Native Method) E/CameraCaptureSession(18048): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/CameraCaptureSession(18048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/CameraCaptureSession(18048): Caused by: android.os.ServiceSpecificException: checkPidStatus:2085: The camera device has been disconnected (code 4) E/CameraCaptureSession(18048): at android.os.Parcel.createExceptionOrNull(Parcel.java:3025) E/CameraCaptureSession(18048): at android.os.Parcel.createException(Parcel.java:2995) E/CameraCaptureSession(18048): at android.os.Parcel.readException(Parcel.java:2978) E/CameraCaptureSession(18048): at android.os.Parcel.readException(Parcel.java:2920) E/CameraCaptureSession(18048): at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.cancelRequest(ICameraDeviceUser.java:648) E/CameraCaptureSession(18048): at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:97) E/CameraCaptureSession(18048): ... 12 more D/[DefaultVideoRenderer(native)](18048): VideoRenderOpenGles20: id 0 D/[DefaultVideoRenderer(native)](18048): Setup: width 303, height 495 D/[DefaultVideoRenderer(native)](18048): Setup: number of textures 16, size 16384 E/flutter (18048): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view. E/flutter (18048): at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:238) E/flutter (18048): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:122) E/flutter (18048): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60) E/flutter (18048): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/flutter (18048): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter (18048): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/flutter (18048): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter (18048): at android.os.Handler.handleCallback(Handler.java:942) E/flutter (18048): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter (18048): at android.os.Looper.loopOnce(Looper.java:201) E/flutter (18048): at android.os.Looper.loop(Looper.java:288) E/flutter (18048): at android.app.ActivityThread.main(ActivityThread.java:7898) E/flutter (18048): at java.lang.reflect.Method.invoke(Native Method) E/flutter (18048): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/flutter (18048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/flutter (18048): , null, null) E/flutter (18048): #0 StandardMethodCodec.decodeEnvelope E/flutter (18048): #1 MethodChannel._invokeMethod E/flutter (18048): E/flutter (18048): #2 TextureAndroidViewController._sendCreateMessage E/flutter (18048): E/flutter (18048): #3 AndroidViewController.create E/flutter (18048): E/flutter (18048): #4 AndroidViewController.setSize E/flutter (18048): E/flutter (18048): #5 RenderAndroidView._sizePlatformView E/flutter (18048): E/flutter (18048): D/ (18048): OneToOneVideo.session.onStreamReceived(SESSION_TOKEN, 94CF63A3-7AD2-4476-ABF2-0C9B8FE246AA) D/ (18048): OneToOneVideo.publisher.onStreamCreated(94CF63A3-7AD2-4476-ABF2-0C9B8FE246AA, 94CF63A3-7AD2-4476-ABF2-0C9B8FE246AA) W/System (18048): A resource failed to call Surface.release. E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(18048): [SurfaceTexture-0-18048-0](id:468000000003,api:1,p:545,c:18048) dequeueBuffer: BufferQueue has been abandoned Application finished. Exited ```
devwithzachary commented 1 year ago

Thank you for the report, these examples are "community supported" which means we don't officially support them. However, I will do my best to debug with the sample you have provided (thank you!) and get back to you if I can find the issue.

mkashifmehmood7 commented 1 year ago

@devwithzachary

I'm also getting the same issue. I've attached the logs for your reference and after these logs "BufferQueue has been abandoned" log continuously occur. Kindly look into it. Thank you

`2022-12-14 00:03:31.201 12170-12823/com.onebarrow.idoctoraccess E/flutter: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view. at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:238) at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:122) at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:255) at android.app.ActivityThread.main(ActivityThread.java:8212) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049) , null, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)

#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
<asynchronous suspension>
#2      TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1146:18)
<asynchronous suspension>
#3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:792:5)
<asynchronous suspension>
#4      AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:819:7)
<asynchronous suspension>
#5      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:182:29)
<asynchronous suspension>`
mkashifmehmood7 commented 1 year ago

@devwithzachary any update ?

devwithzachary commented 1 year ago

As I mentioned above this project is community supported so not something we can provide official support for, and I was on holiday these past 3 weeks so haven't had a chance to look. If/when I do get a chance I will update the ticket accordingly

rituapplocum commented 1 year ago

@devwithzachary @mkashifmehmood7 Did you got any solution? I am also facing the above issue the call gets successfully connected first time but when user press the back button and trys to rejoin the same call the UI for video does not render in Android and throws:- **java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view.**

jttuboi commented 1 year ago

When I was doing this feature, I made this above. I haven't checked if the issue keeps going, but solved when I implemented. I recommend to look the difference between AndroidView and PlatformViewLink.

Other think I did is never close this view, so in other words, the communication between Tokbox and the app keeps the same and not refresh. I don't know is the best solution, but it works.

class VideoCallView extends StatelessWidget {
  const VideoCallView({super.key});

  @override
  Widget build(BuildContext context) {
    if (defaultTargetPlatform == TargetPlatform.android) {
      return PlatformViewLink(
        viewType: openTokViewType,
        surfaceFactory: (_, controller) {
          return AndroidViewSurface(
            controller: controller as AndroidViewController,
            gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
            hitTestBehavior: PlatformViewHitTestBehavior.transparent,
          );
        },
        onCreatePlatformView: (params) {
          return PlatformViewsService.initExpensiveAndroidView(
            id: params.id,
            viewType: openTokViewType,
            layoutDirection: TextDirection.ltr,
            creationParams: {},
            creationParamsCodec: const StandardMessageCodec(),
            onFocus: () => params.onFocusChanged(true),
          )
            ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
            ..create();
        },
      );
    }
    return const UiKitView(
      viewType: openTokViewType,
      creationParams: {},
      creationParamsCodec: StandardMessageCodec(),
    );
  }
}