CommunityToolkit/WindowsCommunityToolkit

Too aggressive cache for CameraHelper

Open

#3.154 geöffnet am 28. Feb. 2020

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (1.403 Forks)batch import
Hacktoberfestbug :bug:good first issuehelpers :raised_hand:improvements :sparkles:

Repository-Metriken

Stars
 (5.708 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide