MCVE: https://github.com/cybex-dev/WKWebView
Post
Replies
Boosts
Views
Activity
Asking with hopes that someone has run into or replicated or even resolved this issue:
In my WKWebView (targeting both macOS 11.0 & 12.4), navigator.mediaDevices.getUserMedia() hangs as promise when called, and never shows a prompt as one expects when running this on e.g. https://google.com.
Full write-up with info, MCVe, etc found here: https://developer.apple.com/forums/thread/734363
As previously suggested, I've added:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
</dict>
and also NSAllowsArbitraryLoads with no luck.
To be clear, navigator.mediaDevices.getUserMedia() and navigator.mediaDevices.enumerateDevices() are both defined:
getUserMedia() hangs on promise
enumerateDevices() returns an single (default) MediaInfoDevice audioinput before & after asking permissions (via getUserMedia or native microphone permissions via AVCaptureDevice)
UPDATE 1
I came across this link:
https://stackoverflow.com/questions/66048995/avaudioengine-halc-shellobject-errors-no-audio-what-can-i-even-look-for
enumerateDevices shows:
0: InputDeviceInfo {deviceId: 'default', kind: 'audioinput', label: 'Default - Internal Microphone (Built-in)', groupId: '...'}
1: InputDeviceInfo {deviceId: '...', kind: 'audioinput', label: 'Internal Microphone (Built-in)', groupId: '...'}
2: InputDeviceInfo {deviceId: '...', kind: 'audioinput', label: 'Microsoft Teams Audio Device (Virtual)', groupId: '...'}
3: InputDeviceInfo {deviceId: '', kind: 'videoinput', label: '', groupId: ''}
4: MediaDeviceInfo {deviceId: 'default', kind: 'audiooutput', label: 'Default - Internal Speakers (Built-in)', groupId: '...'}
5: MediaDeviceInfo {deviceId: '...', kind: 'audiooutput', label: 'Internal Speakers (Built-in)', groupId: '...'}
6: MediaDeviceInfo {deviceId: '...', kind: 'audiooutput', label: 'Microsoft Teams Audio Device (Virtual)', groupId: '...'}
Hardened Runtime Permissions:
Audio Input
Camera
Below is the output for both with and without the above permissions:
WITH
getDevices: nil // JS response
2023-07-25 14:32:19.758054+0200 WKWebView[60215:1070748] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000266820> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2023-07-25 14:32:19.786676+0200 WKWebView[60215:1070748] saved enable noise cancellation setting is the same as the default (=1)
2023-07-25 14:32:19.833763+0200 WKWebView[60215:1070748] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000271760> 30010C1C-93BF-11D8-8B5B-000A95AF9C6A
2023-07-25 14:32:19.855809+0200 WKWebView[60215:1070748] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000271760> 30010C1C-93BF-11D8-8B5B-000A95AF9C6A
2023-07-25 14:32:19.862903+0200 WKWebView[60215:1070703] HALC_ShellObject::GetPropertyData: call to the proxy failed, Error: 1852797029 (nope)
2023-07-25 14:32:19.862932+0200 WKWebView[60215:1070703] HALPlugIn::ObjectGetPropertyData: got an error from the plug-in routine, Error: 1852797029 (nope)
2023-07-25 14:32:19.864197+0200 WKWebView[60215:1070703] HALC_ShellObject::GetPropertyData: call to the proxy failed, Error: 1852797029 (nope)
2023-07-25 14:32:19.864239+0200 WKWebView[60215:1070703] HALPlugIn::ObjectGetPropertyData: got an error from the plug-in routine, Error: 1852797029 (nope)
2023-07-25 14:32:19.865446+0200 WKWebView[60215:1070703] HALC_ShellObject::GetPropertyData: call to the proxy failed, Error: 1852797029 (nope)
2023-07-25 14:32:19.865476+0200 WKWebView[60215:1070703] HALPlugIn::ObjectGetPropertyData: got an error from the plug-in routine, Error: 1852797029 (nope)
2023-07-25 14:32:19.867520+0200 WKWebView[60215:1070703] HALC_ShellObject::GetPropertyData: call to the proxy failed, Error: 1852797029 (nope)
2023-07-25 14:32:19.867541+0200 WKWebView[60215:1070703] HALPlugIn::ObjectGetPropertyData: got an error from the plug-in routine, Error: 1852797029 (nope)
and,
WITHOUT
navigator.mediaDevices is undefined (as expected by Mozilla's documentation on secure environments & mediaDevices), resulting in the following output:
getDevices error: Optional(Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=14, WKJavaScriptExceptionMessage=TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.enumerateDevices'), WKJavaScriptExceptionColumnNumber=39, WKJavaScriptExceptionSourceURL=file:///Users/mac/Library/Caches/JetBrains/AppCode2023.1/DerivedData/WKWebView-gziqxifpucvqvngtmvedcjalfcqj/Build/Products/Debug/WKWebView.app/Contents/Resources/index.html, NSLocalizedDescription=A JavaScript exception occurred})
@Mr.Moro @suMac
Maybe these are worth a look:
https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications
https://stackoverflow.com/questions/62377410/trying-to-customize-notifications-in-macos-with-swift