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

Selecting a link in a WebView on iOS causes a NSInternalInconsistencyException #17923

Closed
edgarssults opened this issue Oct 10, 2023 · 4 comments
Labels
area-controls-webview WebView platform/iOS 🍎 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@edgarssults
Copy link

edgarssults commented Oct 10, 2023

Description

Selecting any link in a WebView by pressing and holding always causes a crash on iOS.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[Microsoft_Maui_Platform_MauiWebViewUIDelegate webView:contextMenuConfigurationForElement:completionHandler:] was not called'

There seems to be a problem with how the context menu is configured by MAUI. The problematic code is apparently here.

It works fine on Android. Selecting normal text also works fine and the context menu appears.

Related issue: #11544

Steps to Reproduce

  1. Create a MAUI app with one WebView on the main page.
  2. Load any URL that displays links (anchors) in the WebView.
  3. Start the app on an iOS device.
  4. Try to press and hold on the link to select it.

Actual behavior:
App crashes.

Expected behavior:
Link or part of the link is selected and a context menu appears.

Link to public reproduction project repository

https://github.com/edgarssults/maui-ios-crash

Version with bug

7.0.92

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17.0.3

Did you find any workaround?

Creating a custom WebViewHandler that initializes a custom WebView on iOS where AllowsLinkPreview is set to false prevents this crash.

Relevant log output

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[Microsoft_Maui_Platform_MauiWebViewUIDelegate webView:contextMenuConfigurationForElement:completionHandler:] was not called'
@edgarssults edgarssults added the t/bug Something isn't working label Oct 10, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 11, 2023
@jsuarezruiz jsuarezruiz added platform/iOS 🍎 and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Oct 11, 2023
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 11, 2023
@gerneio
Copy link

gerneio commented Oct 17, 2023

Having an identical issue using the built-in MAUI WebView control on iOS (.NET 7). Found two workarounds:

  1. Implement custom UIDelegate derived from MauiWebViewUIDelegate and make sure that SetContextMenuConfiguration:completionHandler() is always called (as demonstrated by @anton-yashin here).

  2. Set WKWebView.AllowsLinkPreview to false, IF you don't need iOS preview popups (as suggested by OP @edgarssults here).

I had already implemented my own custom handler, so I implemented both fixes above, just in-case.

@jaosnz-rep
Copy link

jaosnz-rep commented Mar 1, 2024

Verified this issue with Visual Studio Enterprise 17.10 Preview 1.0, not repro on .NET 8.0 iOS platform with sample project.
https://github.com/edgarssults/maui-ios-crash

@jaosnz-rep jaosnz-rep added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Mar 1, 2024
@ghost
Copy link

ghost commented Mar 1, 2024

Hi @edgarssults. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@edgarssults
Copy link
Author

Reproduced with Visual Studio 17.9.2, net8.0-ios, MAUI 8.0.7.
Haven't tried VS preview yet as I don't install those on my current PC.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-webview WebView platform/iOS 🍎 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants