dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.95k stars 1.7k forks source link

MAUI Blazor - navigator.requestMediaKeySystemAccess and window.MediaKeys are undefined on Mac Catalyst #21255

Open mrlife opened 5 months ago

mrlife commented 5 months ago

Description

On iOS device (17.4), iOS simulator (17.4), and Android simulator, navigator.requestMediaKeySystemAccess and window.MediaKeys are defined, however they are not on Mac Catalyst.

Steps to Reproduce

Please see the linked sample app that reproduces the issue. As soon as the app launches, a JavaScript alert will display for each of navigator.requestMediaKeySystemAccess and window.MediaKeys, indicating whether it exists.

Expected behavior is that navigator.requestMediaKeySystemAccess and window.MediaKeys exist on Mac Catalyst like they do on the other platforms.

Link to public reproduction project repository

https://github.com/mrlife/MediaKeysTest

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS Sonoma 14.4

Did you find any workaround?

No response

Relevant log output

No response

jaosnz-rep commented 5 months ago

Verified on VS for Mac 17.6.10 build 428 (8.0.7), can repro issue with sample project on MacCatalyst platform. Screenshot 2024-03-18 134050 Screenshot 2024-03-18 134110

mrlife commented 5 months ago

@jaosnz-rep, thanks for checking it out and verifying the repro. I am on the same version of VS for Mac. I was a little unsure what you meant by "can not repro", though.

For the dotnet-policy-service comment, what version is the comment asking I use? Here is what I have, which seems to be the latest.

.NET SDK: Version: 8.0.203 Commit: 5e1ceea679 Workload version: 8.0.200-manifests.a7f084b6

Runtime Environment: OS Name: Mac OS X OS Version: 14.4 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/8.0.203/

.NET workloads installed: [maui-maccatalyst] Installation Source: SDK 8.0.200 Manifest Version: 8.0.7/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.7/WorkloadManifest.json Install Type: FileBased

[wasi-experimental] Installation Source: SDK 8.0.200 Manifest Version: 8.0.3/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.workload.mono.toolchain.current/8.0.3/WorkloadManifest.json Install Type: FileBased

[maui-android] Installation Source: SDK 8.0.200 Manifest Version: 8.0.7/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.7/WorkloadManifest.json Install Type: FileBased

[ios] Installation Source: SDK 8.0.200 Manifest Version: 17.2.8043/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.ios/17.2.8043/WorkloadManifest.json Install Type: FileBased

[maccatalyst] Installation Source: SDK 8.0.200 Manifest Version: 17.2.8043/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maccatalyst/17.2.8043/WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.3 Architecture: arm64 Commit: 9f4b1f5d66

.NET SDKs installed: 8.0.100 [/usr/local/share/dotnet/sdk] 8.0.101 [/usr/local/share/dotnet/sdk] 8.0.102 [/usr/local/share/dotnet/sdk] 8.0.203 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

jaosnz-rep commented 5 months ago

Sorry @mrlife , the description in the previous comment is wrong, and the error is reproduced on the macOS platform.

Eilon commented 4 months ago

This is likely a limitation of the MacCatalyst native WebView control. I added this HTML to a regular WebView and it showed the items are not available:

    <div>
        <button onclick="alert('requestMediaKeySystemAccess = ' + navigator.requestMediaKeySystemAccess)">requestMediaKeySystemAccess?</button>
        <button onclick="alert('MediaKeys = ' + window.MediaKeys)">MediaKeys?</button>
        <button onclick="alert('location.href = ' + window.location.href)">location.href?</button>
    </div>

(And I also added location.href just to see that something was working.)

This issue likely needs to be reported via Apple Feedback Assistant.

mrlife commented 4 months ago

Hi @Eilon, thank you for checking this situation and corroborating the issue. Do you know if the native WebView used on Mac Catalyst is a WkWebView or something else?

Eilon commented 4 months ago

On MacCatalyst it's also WKWebView.