uno: Mac Catalyst (arm64): WebView is blocking keyboard input
Current behavior
Add a UnoWKWebView, WebView or WKWebView to the UI (code-behind or in XAML does not matter)
The browser control accepts mouse inputs. The browser control does not accept keyboard inputs.
Also, global shortcuts like CMD-Q (quit app) do not work anymore, they seem to be blocked
I know that this worked in earlier v4.x versions of Uno
This happens for both maccatalyst-arm64 as well as maccatalyst-x64
Expected behavior
WebView should accept keyboard input, and not block global shortcuts
How to reproduce it (as minimally and precisely as possible)
See the attached repro, it is just an empty project with a mainpage, in whose constructor I placed this code:
var webView = new UnoWKWebView();
webView.LoadRequest(new Foundation.NSUrlRequest(new Foundation.NSUrl("https://github.com")));
Content = webView;
Workaround
I don’t know of any workarounds, any workaround (if possible) would be appreciated
Works on UWP/WinUI
Yes
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
Uno.WinUI, v4.5.9
Uno.WinUI, v4.6.0-dev.253
Affected platforms
macOS
IDE
Visual Studio for Mac
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 40 (26 by maintainers)
Hi Uno folks, I work at Microsoft on .NET MAUI and Blazor Hybrid and we’re having what seems to be the exact same issue with WKWebView on MacCatalyst. I reproed the same issue using Xcode and Swift to build a MacCatalyst app, just to make sure it wasn’t an issue in the .NET layer (it wasn’t). I filed an Apple Feedback issue with a detailed bug report and repro steps.
You can see a bit more on this issue: https://github.com/dotnet/maui/issues/13934#issuecomment-1480380796
The Apple Feedback issue ID is FB12076485 (though I don’t think it’s publicly visible anywhere).
I just checked the Apple Feedback Assistant item and unfortunately there are no updates on it.
I was testing on an x64 (Intel core i7) Mac with Ventura 13.1
How Microsoft deals with Mac Catalyst is a bit weird. It’s a JITed application for
x64that requires the interpreter (or it crash) or an AOTed application forarm64(or Apple rejects the app) without the interpreter (or it crash).That means there’s a lot of differences between the binaries for both architectures. Starting with their sizes… 4.4 vs 207 MB for debug builds.
Something happens on
arm64that affects/breaks the keyboard input. It might be something inside Uno (since a simple test app with the MS SDK works) or something else that gets included (the linked output won’t be identical and, next step, needs to be analyzed).The easy workaround (at least for now) would be to build/ship only the
x64version of the application and let Rosetta do it’s magic for arm64-based Macs.This works fine on an Apple silicon (M2) Mac when Rosetta is used. IOW it’s related to the binary architecture (x64 works, arm64 does not), not the Uno code itself.
This is likely an Apple bug (looking thru them) and I’ll see if I can find a workaround.
@Eilon Any update on this issue or workaround? After almost a year since your last update, it seems pretty bewildering to me that apple would let such a fundamental issue exist for so long. Why would anyone even want to use a Catalyst app when it doesn’t provide the basic functionality of keyboard navigation?
@Eilon have you ever heard back from Apple about this ? thanks!
Swift app built for arm64 and running on arm64 -> works!
For some reason the app crash (very early at startup) when I build for
x64https://gist.github.com/spouliot/4ef368f9717f3d66adad96e59f436730
I got to go now - but I’ll look at why this crashed asap
And I 100% agree with this and will join you 😄
If possible, could you try running my Swift example on your Apple arm64 machine? This here: https://github.com/Eilon/MacCatalystWebViewKeyboard
It’s a default Swift app I made in Xcode, and then found some code that creates a webview, and then I had it load static HTML. That 100% non-Microsoft app (no .NET, no C#, no Xamarin/MAUI etc.) doesn’t work on my Intel x64 Venture machine on MacCatalyst. The exact same project works fine on iPadOS.
I wonder if that repros on your Apple Silicon on either MacCat or iPadOS?
Using
instead of
does not change the behaviour… which kind of exclude most of the Uno specific code.
That debugging issue was a red herring 😦
The debugging path changed (while trying workarounds) so the binaries were not identical. After rebuilding the new binaries they behave identically between the debugger and the command-line executions (but still different between
x86andarm64).Now I have to re-compare the logs between the
x86andarm64-but they should be identical, IOW I still expect to see a problem with😦UITextInputonarm64only…and, as expected, both
custom-linker-options.txtfiles are identical - except for the paths…I’m diffing the bin logs… which gives a quite large output, stay tuned.
For reference, this is the closest reported issue I found https://developer.apple.com/forums/thread/721141 but the answer I got (from the OP) is diverging from this case (issues with x64, nor arm64).
You can ask the MS folks (either the iOS/Mac or Mono teams) on Discord (DotNetEvolution) but I can answer that too 😃
This was the size of the executable binaries, not the full application bundles.
4.4 MB (for
x64) is very small since it’s JITed (and interpreted). So the executable size is mostly the Mono runtime and a few bits of native code. This means the.dllcontains both the IL and the metadata.207 MB (for
arm64) is huge but everything it fully AOTed (there won’t be any JITing or interpreting at runtime). The executable size contains all the code, there’s no IL (at least for release builds) inside the.dll, only the metadata.As Ahead of Time (AOT) means compiling every at build time you end up with a much larger executable (even if the linker helps a lot) and much longer build times. However you (generally) have much better performance at runtime, in particular application startup times are much better.
As expected using a
WKWebView, instead of theUnoWKWebView, has the same behaviour.OTOH this seems to work fine when using directly the Microsoft SDK (net7.0-maccatalyst).