Skip to content

[webview_flutter_wkwebview] Callback methods shouldn't assert error is null #140410

@bparrishMines

Description

@bparrishMines

Use case

This was created because of the discussion from: flutter/packages#5455 (comment)

webview_flutter_wkwebview handles error received from Flutter callback methods by asserting that there wasn't an error:

  [self.navigationDelegateAPI didFailNavigationForDelegate:self
                                                   webView:webView
                                                     error:error
                                                completion:^(FlutterError *error) {
                                                  NSAssert(!error, @"%@", error);
                                                }];

This would cause a crash whenever there was an error and the app was ran with asserts enabled (e.g. in debug mode). This was done because if an unexpected error was thrown on the Dart side, the NSAssert would print the error and stacktrace, but will be ignored in released mode. But as stated by @stuartmorgan

I guess the question here is: if a plugin client throws an exception in their own Dart code that implements the handler, do we want the entire application to crash?

Is it reasonable that if a client intentionally throws an exception in a callback method, that the app would crash in debug mode, but the error would be ignored in release mode. If not, we should find an alternative handling.

Proposal

Alternatively, we could switch this to an NSLog to still receive the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: webviewThe WebView pluginteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions