flutter_inappwebview icon indicating copy to clipboard operation
flutter_inappwebview copied to clipboard

Android issue: Unknown feature SUPPRESS_ERROR_PAGE, webview not displaying at all

Open kasperkowalski opened this issue 9 months ago • 52 comments

  • [x] I have read the Getting Started section
  • [x] I have already searched for the same problem

Environment

Technology Version
Flutter version Flutter (Channel stable, 3.22.1)
Plugin version ^6.0.0
Android version Android toolchain - develop for Android devices (Android SDK version 34.0.0)
iOS version 17.2
macOS version macOS 14.1.2 23B92 darwin-arm64
Xcode version 15.1
Google Chrome version 124.0.6367.179
Gradle 8.4

Device information: | SM G950F (mobile) | android-arm64 | Android 9 (API 28) | | sdk gphone64 arm64 (mobile) | android-arm64 | Android 13 (API 33) (emulator) |

Description

Expected behavior: Widget with webview should be visible.

Current behavior: Widget with webview is not visible on Android after upgrade plugin to v.6.0.0, worked fine on v.5.8.0 and is working fine on iOS in both versions.

Steps to reproduce

  1. Widget code:
Widget build(BuildContext context) {

final html = """
    <html lang="pl">
    <meta name="viewport" content="width=100, initial-scale=1, user-scalable=no">
    <style>iframe {max-width:100%; border: 0; overflow:hidden;} </style>
    <style>html,body { margin: 0; } </style>
    <body>
      <div class="container" id="_flutter_target_do_not_delete">$replacedHtml</div>
      <script>
      function outputsize() {
          if (typeof window.flutter_inappwebview !== "undefined" && typeof window.flutter_inappwebview.callHandler !== "undefined")
              window.flutter_inappwebview.callHandler('newHeight', document.getElementById("_flutter_target_do_not_delete").firstChild.offsetHeight);
          }
        new ResizeObserver(outputsize).observe(_flutter_target_do_not_delete)
      </script>
    </body>
    </html>
""";

    final Widget webviewWidget = SizedBox(
      height: height,
      width: double.infinity,
      child: InAppWebView(
        initialData: InAppWebViewInitialData(data: html),
        initialSettings: InAppWebViewSettings(
          transparentBackground: true,
          supportZoom: false,
          disableHorizontalScroll: true,
          disableVerticalScroll: true,
        ),
        onWebViewCreated: (InAppWebViewController controller) {
          controller.addJavaScriptHandler(
            handlerName: 'newHeight',
            callback: (List<dynamic> arguments) async {
              final contentHeight = await controller.getContentHeight();
              final zoomScale = await controller.getZoomScale();
              final htmlHeight = contentHeight!.toDouble() * zoomScale!;
              final htmlHeightFixed =
                  double.parse(htmlHeight.toStringAsFixed(2));
              if (htmlHeightFixed == 0.0) {
                return;
              }

              final int? innerHeight;
              if (arguments.isNotEmpty) {
                innerHeight = arguments[0] as int;
              } else {
                innerHeight = await controller.getContentHeight();
              }

              if (mounted) {
                setState(
                  () =>
                      height = (innerHeight != null &&
                              innerHeight.toDouble() > htmlHeightFixed)
                          ? innerHeight.toDouble()
                          : htmlHeightFixed,
                );
              }
            },
          );
        },
      ),
    );

    if (widget.disablePadding ?? false) {
      return webviewWidget;
    }

    return Column(
      children: [
        TabletMargins(
          mobilePadding: AppSpacing.lg,
          child: webviewWidget,
        ),
        const SizedBox(),
      ],
    );
  1. console output:
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
I/flutter (16853): Fetching article: 40431721
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 0
D/InAppWebView(16853): Using InAppWebViewClientCompat implementation
W/cr_SupportWebSettings(16853): setForceDark() is a no-op in an app with targetSdkVersion>=T
W/cr_SupportWebSettings(16853): setForceDarkBehavior() is a no-op in an app with targetSdkVersion>=T
E/MethodChannel#flutter/platform_views(16853): Failed to handle method call
E/MethodChannel#flutter/platform_views(16853): java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
E/MethodChannel#flutter/platform_views(16853): 	at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:640)
E/MethodChannel#flutter/platform_views(16853): 	at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:609)
E/MethodChannel#flutter/platform_views(16853): 	at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:600)
E/MethodChannel#flutter/platform_views(16853): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
E/MethodChannel#flutter/platform_views(16853): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
E/MethodChannel#flutter/platform_views(16853): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:525)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:170)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter/platform_views(16853): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter/platform_views(16853): 	at android.os.Handler.handleCallback(Handler.java:873)
E/MethodChannel#flutter/platform_views(16853): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter/platform_views(16853): 	at android.os.Looper.loop(Looper.java:214)
E/MethodChannel#flutter/platform_views(16853): 	at android.app.ActivityThread.main(ActivityThread.java:7050)
E/MethodChannel#flutter/platform_views(16853): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views(16853): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/MethodChannel#flutter/platform_views(16853): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
[log] PlatformException(error, Unknown feature SUPPRESS_ERROR_PAGE, null, java.lang.RuntimeException: Unknown feature SUPPRESS_ERROR_PAGE
      	at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:640)
      	at androidx.webkit.internal.WebViewFeatureInternal.isSupported(WebViewFeatureInternal.java:609)
      	at androidx.webkit.WebViewFeature.isFeatureSupported(WebViewFeature.java:600)
      	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.prepare(InAppWebView.java:436)
      	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.<init>(FlutterWebView.java:82)
      	at com.pichillilorenzo.flutter_inappwebview_android.webview.FlutterWebViewFactory.create(FlutterWebViewFactory.java:67)
      	at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:525)
      	at io.flutter.plugin.platform.PlatformViewsController$1.createForPlatformViewLayer(PlatformViewsController.java:170)
      	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:105)
      	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
      	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
      	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
      	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:873)
      	at android.os.Handler.dispatchMessage(Handler.java:99)
      	at android.os.Looper.loop(Looper.java:214)
      	at android.app.ActivityThread.main(ActivityThread.java:7050)
      	at java.lang.reflect.Method.invoke(Native Method)
      	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
      	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
      )
[log] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
      #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
      <asynchronous suspension>
      #2      ExpensiveAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1099:5)
      <asynchronous suspension>
      #3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:822:5)
      <asynchronous suspension>
D/ViewRootImpl@8159f1b[MainActivity](16853): ViewPostIme pointer 1

kasperkowalski avatar May 23 '24 11:05 kasperkowalski