Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.79k stars 860 forks source link

[BUG] updateAcquireFence: Did not find frame #1145

Closed chenghuaWang closed 1 year ago

chenghuaWang commented 1 year ago

Describe the bug:

The flutter_html version I used is 2.2.1. And I am trying to bring a HTML video player(Such as YouTube, BiliBili) to the flutter widget. The program works really fine on web(Chrome), but failed on Android(SDK 32). And it throw error updateAcquireFence: Did not find frame.

The full log is bellow:

Performing hot restart...
Syncing files to device sdk gphone64 x86 64...
W/cr_AwContents( 6759): WebView.destroy() called while WebView is still attached to window.
D/EGL_emulation( 6759): app_time_stats: avg=560.89ms min=4.15ms max=23139.30ms count=42
Restarted application in 1,116ms.
D/EGL_emulation( 6759): app_time_stats: avg=738.11ms min=13.07ms max=24434.85ms count=34
D/EGL_emulation( 6759): app_time_stats: avg=20.50ms min=9.96ms max=152.06ms count=47
D/EGL_emulation( 6759): app_time_stats: avg=72.26ms min=9.66ms max=1410.28ms count=33
D/EGL_emulation( 6759): app_time_stats: avg=592.82ms min=14.51ms max=3949.49ms count=7
I/PlatformViewsController( 6759): Hosting view in view hierarchy for platform view: 0
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
W/Parcel  ( 6759): Expecting binder but got null!
D/EGL_emulation( 6759): app_time_stats: avg=53.81ms min=4.89ms max=785.58ms count=25
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
D/EGL_emulation( 6759): app_time_stats: avg=10250.34ms min=10250.34ms max=10250.34ms count=1
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
D/EGL_emulation( 6759): eglCreateContext: 0x766a89375c50: maj 2 min 0 rcv 2
E/flutter ( 6759): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 6759): #0      IframeContentElement.toWidget.<anonymous closure> (package:flutter_html/src/widgets/iframe_mobile.dart:44:50)
E/flutter ( 6759): #1      _PlatformCallbacksHandler.onNavigationRequest (package:webview_flutter/src/webview.dart:461:42)
E/flutter ( 6759): #2      WebViewAndroidWebViewClient.requestLoading (package:webview_flutter_android/webview_android_widget.dart:673:68)
E/flutter ( 6759): #3      WebViewClientFlutterApiImpl.requestLoading (package:webview_flutter_android/src/android_webview_api_impls.dart:693:15)
E/flutter ( 6759): #4      WebViewClientFlutterApi.setup.<anonymous closure> (package:webview_flutter_android/src/android_webview.pigeon.dart:1693:15)
E/flutter ( 6759): #5      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
E/flutter ( 6759): #6      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
E/flutter ( 6759): #7      _invoke2 (dart:ui/hooks.dart:186:13)
E/flutter ( 6759): #8      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
E/flutter ( 6759): #9      _Channel.push (dart:ui/channel_buffers.dart:132:31)
E/flutter ( 6759): #10     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
E/flutter ( 6759): #11     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
E/flutter ( 6759): #12     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
E/flutter ( 6759): 
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
D/EGL_emulation( 6759): app_time_stats: avg=304.19ms min=6.50ms max=1162.98ms count=4
D/EGL_emulation( 6759): app_time_stats: avg=398.01ms min=8.63ms max=1161.21ms count=3
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
D/EGL_emulation( 6759): app_time_stats: avg=246.31ms min=11.03ms max=1119.37ms count=5
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
E/FrameEvents( 6759): updateAcquireFence: Did not find frame.
Application finished.

HTML to reproduce the issue:

The HTML code I used is quite common. <iframe width="$videoWidth" src="https://player.bilibili.com/player.html?aid=80433022&bvid=BV1GJ411x7h7&cid=137649199&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe> where the videoWidth is get from flutter context.

Html widget configuration:

The way I using HTML class is quite straight.

Html(
      data: src_url,
    );

Expected behavior:

It expected to show the widget like below image

Device details and Flutter/Dart/flutter_html versions:

Flutter SDK = ^3.3.2 flutter_html = ^2.2.1

Sub6Resources commented 1 year ago

Please try using flutter_html 3.0.0-alpha.5 along with flutter_html_iframe 3.0.0-alpha.4 to see if that resolves your issue. Thanks!

chenghuaWang commented 1 year ago

3ks, It solved this problem. And I just find flutter_html_iframe 3.0.0-alpha.3 instead of alpha.4, is it a typo ?

Solution just as @Sub6Resources said, Using flutter_html 3.0.0-alpha.5 along with flutter_html_iframe 3.0.0-alpha.3. There is no need to modify the HTML code. The widget is constructed with the settings below:

Html(
      data: src_url,
      style: {
        "iframe": Style(
          width: MediaQuery.of(context).size.width,
          height: (MediaQuery.of(context).size.width / 16.0) * 9.0,
        ),
      },
      customRenders: {
        iframeMatcher(): iframeRender(),
      },
    );
Sub6Resources commented 1 year ago

Ah, yes, that was a typo. Glad it resolved your issue!