CommunityToolkit/WindowsCommunityToolkit

Too aggressive cache for CameraHelper

Open

#3,154 建立於 2020年2月28日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C# (1,403 fork)batch import
Hacktoberfestbug :bug:good first issuehelpers :raised_hand:improvements :sparkles:

倉庫指標

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:

  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:

  • 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: )

貢獻者指南