Too aggressive cache for CameraHelper
#3,154 建立於 2020年2月28日
倉庫指標
- Star
- (5,708 star)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
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:
- Open Sample app
- Unplug camera
- Go to CameraHelper sample
- Go back
- Plug camera back in
- Go to CameraHelper sample again
- 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:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- Insider Build (build number: )
App min and target version:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- Insider Build (xxxxx)
Device form factor:
- Desktop
- Xbox
- Surface Hub
- IoT
Visual Studio
- 2017 (version: )
- 2019 (version: )
- 2019 Preview (version: )