Closed davidbritch closed 2 months ago
#if MACCATALYST
Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("Inspect", (handler, view) =>
{
if (OperatingSystem.IsMacCatalystVersionAtLeast(16, 4))
{
handler.PlatformView.Inspectable = true;
// For older versions .NET Mac Versions that don't include the Inspectable field.
// handler.PlatformView.SetValueForKey(Foundation.NSObject.FromObject(true), new Foundation.NSString("inspectable"));
}
});
#endif
You can set it on the webview directly, then it will appear.
https://github.com/drasticactions/MauiRepros/blob/main/MauiWebviewInspect/MauiProgram.cs#L10
For the Blazor View, there's an object for setting the Inspectable setting (https://github.com/drasticactions/maui/blob/0f764ac98e1a0e0e31b797ec991f8bba896a7c9c/src/BlazorWebView/src/SharedSource/BlazorWebViewDeveloperTools.cs#L13) which made adding the flag easy, since setting that field should have already set the flag. For the standard WebView for iOS/Catalyst, it's a bit tougher, since I don't think there is a standard way across all platforms to enable an "inspectable" view. "WKWebView.Inspectable" should be available in .NET 8+ builds, and accessing that to enable it directly on the platform view seems like a fair trade to do it, verses opting for a new public API to do it.
@Eilon Do you have any thoughts on this?
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
@Eilon Do you have any thoughts on this?
Nothing to add. We could probably do some improvements in general to WebView in the future, perhaps along the lines of what the HybridWebView experiment would add.
I can repro this issue at Maccatalyst platform on the latest 17.6.14 (build 413)(8.0.80 & 8.0.3 & 8.0.0-rc.2.9373), And it also not work on .Net7(7.0.49). After add below workaround, it works fine.
#if MACCATALYST Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("Inspect", (handler, view) => { if (OperatingSystem.IsMacCatalystVersionAtLeast(16, 4)) { handler.PlatformView.Inspectable = true; // For older versions .NET Mac Versions that don't include the Inspectable field. // handler.PlatformView.SetValueForKey(Foundation.NSObject.FromObject(true), new Foundation.NSString("inspectable")); } }); #endif
@kevinxufei What are you testing? If it's BlazorWebView, that was fixed with https://github.com/dotnet/maui/pull/19909, which was inserted in 8.0.7, so anything newer then that should work fine.
If it's WebView or HybridWebView, those are different and should be turned into a new issue, it's unrelated.
Closing due to https://github.com/dotnet/maui/pull/19909
If this is a issue with the newest net8.0 or 9.0 versions, make a new issue.
Description
A .NET 8 Blazor Hybrid app running on Mac Cat is inspectable in Safari Dev tools:
This is because there are PRs (https://github.com/dotnet/maui/pull/14610 and https://github.com/dotnet/maui/pull/16631) to re-enable this functionality for
BlazorWebView
in .NET 8.However, a .NET 8 MAUI app containing a
WebView
, running on Mac Cat isn't inspectable in Safari Dev tools:In both apps, the required entitlement is present courtesy of the project templates.
It looks like the same inspectable fix for
BlazorWebView
needs inserting intoWebView
.Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
8.0.0-rc.2.9373
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.49
Affected platforms
macOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response