CameraFrames sample throws unhandled exception when new camera is plugged in

Open
#1,131 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale

Research direction

Start with the CameraFrames sample's scenario 2 and reproduce the failure when a USB camera is plugged in after the DeviceWatcher Added event. Inspect the call to MediaFrameSourceGroup.FromIdAsync() and determine whether the sample can avoid the unhandled exception; done means the sample handles this repro without crashing or the issue is confirmed as an OS defect.

Written by the indexing model from the issue text.

Description

camera-and-capture

The CameraFrames sample throws an unhandled exception when a new camera is plugged in.

Repro steps:

  1. Compile CameraFrames sample for Debug/x64 with Visual Studio 2017 (I used 15.9.15) targeting Windows 10 1903/18382.
  2. Run the sample and select scenario 2 (Find and display all media frame sources).
  3. Plug in a USB camera.

The exception is thrown in the call to MediaFrameSourceGroup.FromIdAsync(). The exception is The system cannot find the file specified. (Exception from HRESULT: 0x80070002).

I suspect there's a race condition here. If I set a breakpoint on the FromIdAsync() call and step over it in the debugger then the call succeeds. In fact, if I do something gross like let the first call fail but catch the exception and then try the call again it succeeds on the second call.

It seems like you can't call MediaFrameSourceGroup.FromIdAsync() too soon after the DeviceWatcher raises the Added event (after the initial enumeration is complete) or you'll hit this apparent race condition.

I'm running Windows 10 Pro 1903 build 18362.295.

I originally filed this as a doc bug here but I suspect it's really an OS bug.

Dominant language
JavaScript
Stars
9.7k
Forks
7.8k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/Windows-universal-samples

All issues in microsoft/Windows-universal-samples

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.