MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Prevent mic/webcam access via getUserMedia being terminated when app is minimised
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I am using WebView2 in a WinUI2 UWP app to develop "MS Teams-like" functionality. We use HTML5 getUserMedia() to get access to a MediaStream from the user's webcam/microphone for streaming to a WebRTC call. I'm finding that access to both are being terminated every time the user minimises the app.
This MSDN forum post suggests it is possible to keep the camera alive using an extended session. I've tried this in EnteringBackground event of Application in App.xaml.cs but the camera stops regardless, even though the extended execution request is granted and app termination deferral succeeds. It stops immediately when the app is minimised. Using the old WebView (or WebView1 if you like) it was possible to prevent this by combining the following code in the Application startup with the Background Media Playback capability:
SystemMediaTransportControls.GetForCurrentView().IsPlayEnabled = true;
SystemMediaTransportControls.GetForCurrentView().IsPauseEnabled = true;
Is there any way to prevent this happening with WebView2 in WinUI2.8 pre-release for UWP? It makes a WebRTC type application like MS teams virtually unusable.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the UWP app lifecycle handling in App.xaml.cs, especially the EnteringBackground event and extended execution request. Compare the WebView2 behavior with the older WebView approach using SystemMediaTransportControls and Background Media Playback. Done means establishing whether getUserMedia streams can remain active after minimization and documenting a supported fix or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- audio-video-rtc, desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100