CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.88k stars 1.38k forks source link

Too aggressive cache for CameraHelper #3154

Open azchohfi opened 4 years ago

azchohfi commented 4 years ago

Describe the bug

The CameraHelper fetches the MediaFrameSourceGroup when it starts, but then it never invalidates that. It's known that "static" is the root of all evil, and this is, again, the case here. It "caches" the MediaFrameSourceGroup here: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp/Helpers/CameraHelper/CameraHelper.cs#L39-L50 But if you disconnect your camera, call this method, and plug your camera in again, it will never detect your camera, and since this is caches on a static field, it will only fetch again if you close the process and open it again.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Open Sample app
  2. Unplug camera
  3. Go to CameraHelper sample
  4. Go back
  5. Plug camera back in
  6. Go to CameraHelper sample again
  7. Camera will not show up

Expected behavior

The list of MediaFrameSourceGroup should change if there is a new device detected. We should create a DeviceWatcher and refresh that list when there is a device change.

NuGet Package(s): Latest 6.0.0

Package Version(s): Latest 6.0.0

Windows 10 Build Number:

App min and target version:

Device form factor:

Visual Studio

ghost commented 4 years ago

Hello azchohfi, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost commented 4 years ago

Hello azchohfi, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌