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

[webview_flutter] Adds platform implementations for onHttpError callback #3695

Conversation

HugoOlthof
Copy link
Contributor

Reference #3278

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan
Copy link
Contributor

We should make sure #3675 gets the baseline file updates and then lands, and then this has that merged in, before this lands, so that we can better see what the baseline changes here are and if any new warnings are being introduced.

This doesn't have to block initial review, but I'm flagging it now so that we don't forget.

@bparrishMines
Copy link
Contributor

#3675 has been merged, so this PR will need to pull from main and handle the Android lint warnings.

@ghost ghost force-pushed the on-http-error-platform-implementations branch 2 times, most recently from c550592 to d62dfc3 Compare April 18, 2023 11:01
@stuartmorgan stuartmorgan self-requested a review April 18, 2023 20:05
@ghost ghost force-pushed the on-http-error-platform-implementations branch from d62dfc3 to 7a6086a Compare April 20, 2023 07:08
Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM with last few nits

@ghost ghost force-pushed the on-http-error-platform-implementations branch from 7a6086a to 59b12f2 Compare April 21, 2023 07:01
@stuartmorgan stuartmorgan changed the title [webview_flutter_android] [webview_flutter_wkwebview] Adds platform implementations for onHttpError callback [webview_flutter] Adds platform implementations for onHttpError callback Apr 25, 2023
}),
)
..loadRequest(
LoadRequestParams(uri: Uri.parse('https://www.google.com')),
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be primaryUrl, not an actual site. Using real sites in integration tests makes tests much more prone to flake.

..loadRequest(
LoadRequestParams(
uri: Uri.parse(
'https://www.google.nl',
Copy link
Contributor

Choose a reason for hiding this comment

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

primaryUrl

FlutterError *error) {
NSAssert(!error, @"%@", error);
decisionHandler(
FWFNativeWKNavigationResponsePolicyFromEnumData(
Copy link
Contributor

Choose a reason for hiding this comment

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

This has the some problem as the code discussed recently in the permission callback PR; it will unconditionally call the callback with an invalid value if Apple ever adds a new enum value. @bparrishMines Are you going to mass-fix this in a fast follow? I'm concerned about replicating a pattern that we know is dangerous.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fixed now with #3812.

This also only affects enums that we receive from Objective-C. The Dart code shouldn't be able to return an enum the native side doesn't recognize.

) {
if (weakThis.target?._onHttpError != null) {
weakThis.target!._onHttpError!(
HttpResponseError(statusCode: response.statusCode));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused; how is this callback intended to work in practice? You are throwing away the request object before it gets to the client, which means they will have absolutely no way of knowing whether the error is coming from a navigation (and if so to where) or a resource on the page (and if so, what). I'm not clear on what non-trivial use case a client could satisfy without having the request.

Am I missing something here?

Copy link
Contributor

Choose a reason for hiding this comment

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

/cc @bparrishMines who reviewed the overall PR, since it's core to the overall design. (It looks like the main PR only had one review before sub-parts started landing? Ideally that should have been two.)

Copy link
Contributor Author

@HugoOlthof HugoOlthof May 2, 2023

Choose a reason for hiding this comment

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

@stuartmorgan It makes sense to include the request in the HttpResponseError object. Is it better to create a platform specific implementation for HttpResponseError and include the request in there, like AndroidWebResourceError, or include it in the HttpResponseError object itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it seems core to using this correctly, I would include it in the base object; it could be nullable in case there are implementations or cases where it's not available.

Copy link
Contributor

Choose a reason for hiding this comment

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

@stuartmorgan Sorry about that. I've been reviewing all of the WebView PRs as the owner of both the Android and iOS implementation, so I assumed it was fine to be the only approval for the aggregate PR. I'll start getting secondary reviews for those as well.

I agree with creating adding a request object to HttpResponseError.

Copy link
Contributor

Choose a reason for hiding this comment

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

@HugoOlthof
Copy link
Contributor Author

@stuartmorgan @bparrishMines I've added a new PR #4025 which adds the request to the HttpResponseError object.

@stuartmorgan
Copy link
Contributor

Update from triage: the response object PR, which is blocking this, is still in progress.

@stuartmorgan
Copy link
Contributor

Update from triage: still waiting for #4025, then this can proceed.

@bparrishMines bparrishMines added the federated: partial_changes PR that contains changes for only a single package of a federated plugin change label Jul 17, 2023
@Hixie
Copy link
Contributor

Hixie commented Oct 24, 2023

This is blocked on #4025 which is currently in review.

@stuartmorgan
Copy link
Contributor

Update from triage: #5790 has been created as a copy of the blocking PR, to work on unblocking this.

@stuartmorgan
Copy link
Contributor

Update from triage: the blocker has been landed, so this is ready to be updated.

@stuartmorgan
Copy link
Contributor

Closing in favor of the PR cross-linked just above, as this one isn't editable by the Flutter team.

auto-submit bot pushed a commit that referenced this pull request Mar 14, 2024
…plementations for onHttpError (#6149)

Copy of #3695 since it doesn't contain permission to edit from contributors.

Part of flutter/flutter#39502

Full PR #3278
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
…plementations for onHttpError (flutter#6149)

Copy of flutter#3695 since it doesn't contain permission to edit from contributors.

Part of flutter/flutter#39502

Full PR flutter#3278
bill-skdnd pushed a commit to skdnd-metaspace/webview_flutter_wkwebview that referenced this pull request Aug 2, 2024
…plementations for onHttpError (#6149)

Copy of flutter/packages#3695 since it doesn't contain permission to edit from contributors.

Part of flutter/flutter#39502

Full PR flutter/packages#3278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
federated: partial_changes PR that contains changes for only a single package of a federated plugin change p: webview_flutter platform-android platform-ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants