Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes SUPPRESS_ERROR_PAGE warning after webview_flutter_android upgrade #2182

Conversation

Manuito83
Copy link
Contributor

Connection with issue(s)

Resolve issue #2150

Testing and Review Notes

The SUPPRESS_ERROR_PAGE feature was discontinued according to this change in Webkit's WebViewFeature.java.

The recent upgrade of webkit to 1.10.0 in webview_flutter_android causes the webview to be null.

This suppresses references to SUPPRESS_ERROR_PAGE.

@EArminjon
Copy link
Contributor

How override error pages if we no longer have disableDefaultErrorPage ?

@Manuito83
Copy link
Contributor Author

Manuito83 commented Jun 17, 2024

@EArminjon I can't say. This was a feature that was never launched in webkit:

Remove unlaunched suppressErrorPage API
Removing this abandoned API, which was never launched.

This is a change performed in WebViewFeature.java almost a year ago.

@subzero911
Copy link

I need this fix ASAP, because I have this error.
A webview is just blank.

@RaymondGsc
Copy link

@pichillilorenzo I also need this fix, the webview just throw a SUPPRESS_ERROR_PAGE when opening.

@Julied5
Copy link

Julied5 commented Jul 11, 2024

your code does the trick but the webkit update gets me another error if i open a webview in a new flutter page and i pop it, the app just crashes :

E/AndroidRuntime( 4220): java.lang.IncompatibleClassChangeError: Found interface androidx.webkit.ScriptHandler, but class was expected (declaration of 'androidx.webkit.ScriptHandler' appears in /data/app/~~.......
E/AndroidRuntime( 4220): 	at com.pichillilorenzo.flutter_inappwebview_android.types.UserContentController.removeAllPluginScripts(UserContentController.java:310)

i guess it is because the webkit version in build.gradle is still in 1.8.0 (where the ScriptHandler is defined as an abstract class) and in the updated webkit (located in webview_flutter_android) the ScriptHandler is an interface, it creates a conflict between the two versions

if i replace with a newer webkit version (in android/build.gradle line 52) it fixes my bug :

dependencies {
    implementation 'androidx.webkit:webkit:1.11.0'
    implementation 'androidx.browser:browser:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}

@Manuito83 can you tell me if you reproduce as well ?

@Manuito83
Copy link
Contributor Author

I was not getting this error with:

implementation 'androidx.webkit:webkit:1.10.0'

@Julied5
Copy link

Julied5 commented Jul 11, 2024

yes it also works with 1.10.0 but not with the actual one (1.8.0) defined in flutter_inappwebview_android/android/build.gradle

@ndavis-rxss
Copy link

LGTM

@tkreuder
Copy link

tkreuder commented Jul 18, 2024

it worked for me and i bumped implementation 'androidx.webkit:webkit:1.11.0' in build.gradle:

pubspec.yaml

dependency_overrides:
  flutter_inappwebview_android:
    git:
      url: https://github.com/tkreuder/flutter_inappwebview.git
      ref: v6.0.0-fix-suppress-error-page
      path: flutter_inappwebview_android

@EArminjon
Copy link
Contributor

EArminjon commented Jul 19, 2024

Personally i make the fix different to still support disableDefaultErrorPage :

Old code

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
      webView.customSettings.disableDefaultErrorPage) {}

New code (as feature no longer supported and so should match 'false')

if (webView.customSettings.disableDefaultErrorPage) {

I also updated webkit inside android/build.gradle

implementation 'androidx.webkit:webkit:1.11.0'

I can create a new PR for that.

@@ -299,12 +299,6 @@ public void onReceivedError(WebView view, @NonNull WebResourceRequest request, @
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
final InAppWebView webView = (InAppWebView) view;

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
webView.customSettings.disableDefaultErrorPage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just remove !WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) and keep the if

@@ -309,12 +309,6 @@ public void onReceivedError(@NonNull WebView view,
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
final InAppWebView webView = (InAppWebView) view;

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just remove !WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) and keep the if

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep old code format. That make review very hard, didn't see what you have changed.

@RaymondGsc
Copy link

RaymondGsc commented Jul 22, 2024

Personally i make the fix different to still support disableDefaultErrorPage :

Old code

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
      webView.customSettings.disableDefaultErrorPage) {}

New code (as feature no longer supported and so should match 'false')

if (webView.customSettings.disableDefaultErrorPage) {

I also updated webkit inside android/build.gradle

implementation 'androidx.webkit:webkit:1.11.0'

I can create a new PR for that.

Please fix it, I need this update ASAP, thx.

@EArminjon EArminjon mentioned this pull request Jul 22, 2024
3 tasks
@EArminjon
Copy link
Contributor

Personally i make the fix different to still support disableDefaultErrorPage :
Old code

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
      webView.customSettings.disableDefaultErrorPage) {}

New code (as feature no longer supported and so should match 'false')

if (webView.customSettings.disableDefaultErrorPage) {

I also updated webkit inside android/build.gradle

implementation 'androidx.webkit:webkit:1.11.0'

I can create a new PR for that.

Please fix it, I need this update ASAP, thx.

Can you test #2231 ?

@ndavis-rxss
Copy link

@pichillilorenzo

@RaymondGsc
Copy link

Personally i make the fix different to still support disableDefaultErrorPage :
Old code

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
      webView.customSettings.disableDefaultErrorPage) {}

New code (as feature no longer supported and so should match 'false')

if (webView.customSettings.disableDefaultErrorPage) {

I also updated webkit inside android/build.gradle

implementation 'androidx.webkit:webkit:1.11.0'

I can create a new PR for that.

Please fix it, I need this update ASAP, thx.

Can you test #2231 ?

Yes, I have test #2231 , and

Personally i make the fix different to still support disableDefaultErrorPage :
Old code

if (!WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE) &&
      webView.customSettings.disableDefaultErrorPage) {}

New code (as feature no longer supported and so should match 'false')

if (webView.customSettings.disableDefaultErrorPage) {

I also updated webkit inside android/build.gradle

implementation 'androidx.webkit:webkit:1.11.0'

I can create a new PR for that.

Please fix it, I need this update ASAP, thx.

Can you test #2231 ?

I have all the code checked, but I wonder how can I test your code on my own device.

@jwbrown
Copy link

jwbrown commented Aug 23, 2024

I implemented

dependencies {
    implementation 'androidx.webkit:webkit:1.11.0'
    implementation 'androidx.browser:browser:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}

in my projects build.gradle but am still getting the java.lang.IncompatibleClassChangeError

[AndroidInAppWebViewWidget] (android) AndroidInAppWebViewWidget calling "dispose" using []
E/AndroidRuntime(10863): FATAL EXCEPTION: main
E/AndroidRuntime(10863): Process: com.example.letts_news, PID: 10863
E/AndroidRuntime(10863): java.lang.IncompatibleClassChangeError: Found interface androidx.webkit.ScriptHandler, but class was expected (declaration of 'androidx.webkit.ScriptHandler' appears in /data/app/~~qjcoDlweDOdhaTmOimMemg==/com.example.letts_news-ubVVtKNAKvjVDbcv-qI7KA==/base.apk)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.types.UserContentController.removeAllPluginScripts(UserContentController.java:309)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.types.UserContentController.dispose(UserContentController.java:470)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.dispose(InAppWebView.java:2065)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.dispose(FlutterWebView.java:154)
E/AndroidRuntime(10863): 	at io.flutter.plugin.platform.PlatformViewsController$1.dispose(PlatformViewsController.java:254)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.dispose(PlatformViewsChannel.java:150)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:58)
E/AndroidRuntime(10863): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(10863): 	at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(10863): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10863): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(10863): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(10863): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(10863): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10863): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(10863): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

I've been stuck on this for most of the day so any direction would be appreciated

@EArminjon
Copy link
Contributor

EArminjon commented Aug 24, 2024

I implemented

dependencies {
    implementation 'androidx.webkit:webkit:1.11.0'
    implementation 'androidx.browser:browser:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}

in my projects build.gradle but am still getting the java.lang.IncompatibleClassChangeError

[AndroidInAppWebViewWidget] (android) AndroidInAppWebViewWidget calling "dispose" using []
E/AndroidRuntime(10863): FATAL EXCEPTION: main
E/AndroidRuntime(10863): Process: com.example.letts_news, PID: 10863
E/AndroidRuntime(10863): java.lang.IncompatibleClassChangeError: Found interface androidx.webkit.ScriptHandler, but class was expected (declaration of 'androidx.webkit.ScriptHandler' appears in /data/app/~~qjcoDlweDOdhaTmOimMemg==/com.example.letts_news-ubVVtKNAKvjVDbcv-qI7KA==/base.apk)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.types.UserContentController.removeAllPluginScripts(UserContentController.java:309)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.types.UserContentController.dispose(UserContentController.java:470)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView.dispose(InAppWebView.java:2065)
E/AndroidRuntime(10863): 	at com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView.dispose(FlutterWebView.java:154)
E/AndroidRuntime(10863): 	at io.flutter.plugin.platform.PlatformViewsController$1.dispose(PlatformViewsController.java:254)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.dispose(PlatformViewsChannel.java:150)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:58)
E/AndroidRuntime(10863): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime(10863): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(10863): 	at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(10863): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10863): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(10863): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(10863): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(10863): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10863): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(10863): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

I've been stuck on this for most of the day so any direction would be appreciated

You can try #2231

I use it inside a big app in production, it works well.

@jwbrown
Copy link

jwbrown commented Aug 24, 2024

@EArminjon

Cannot thank you enough, this worked for me.

Strangely i could not just clone and checkout the PR and build - have some weird problems in my flutter config still.... I was however able to patch .pub-cache with the changes and it fixes the problem perfectly.

Again thanks! I hope the change is merged into the package

Jim

@kassandra-all-win-software

it worked for me and i bumped implementation 'androidx.webkit:webkit:1.11.0' in build.gradle:

pubspec.yaml

dependency_overrides:
  flutter_inappwebview_android:
    git:
      url: https://github.com/tkreuder/flutter_inappwebview.git
      ref: v6.0.0-fix-suppress-error-page
      path: flutter_inappwebview_android

It's Works for me

@pichillilorenzo
Copy link
Owner

Released new version 6.1.0 with the fix, thanks!

@abdallah-odeh
Copy link

@pichillilorenzo is this update requires to have SDK version 3.5.0 or it might be used on a lower bound? because it's kinda high & not everyone has updated to latest version

The current Dart SDK version is 3.4.3.

Because app_namespace depends on flutter_inappwebview >=6.1.0 which requires SDK version >=3.5.0 <4.0.0, version solving failed.


You can try the following suggestion to make the pubspec resolve:
* Consider downgrading your constraint on flutter_inappwebview: flutter pub add flutter_inappwebview:^6.0.0

@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Sep 24, 2024

@abdallah-odeh currently the InAppWebView widget for MacOS is only supported correctly starting from Flutter version ">=3.24.0" (which is based on Dart 3.5.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.