CameraPreview freezes after few frames.
Describe the bug
When I try to use sample codes of CameraPreview, the camera frame freezes after few frames.__
Steps to reproduce
1. Create new project -> Template Studio for WinUI(Template Studio version:5.5), all default.
2. Use defalut Microsoft.WindowsAppSDK(1.4.231008000) and Microsoft.Windows.SDK.BuildTools(10.0.22621.756)
3. Install CommunityToolkit.WinUI.Controls.CameraPreview 8.0.230907
4. Add sample codes on https://github.com/CommunityToolkit/Windows/blob/main/components/CameraPreview/samples/CameraPreviewSample.xaml and https://github.com/CommunityToolkit/Windows/blob/main/components/CameraPreview/samples/CameraPreviewSample.xaml.cs
5. Build Debug x64 Packaged
6. Camera frames stops updating 2 seconds after app launch
Expected behavior
Camera frame keeps updating.
Screenshots
No response
Code Platform
- [ ] UWP
- [X] WinAppSDK / WinUI 3
- [ ] Web Assembly (WASM)
- [ ] Android
- [ ] iOS
- [ ] MacOS
- [ ] Linux / GTK
Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 10 21H2 (Build 19044)
- [ ] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [X] Other (specify)
Other Windows Build number
Windows 11 23H2 (Build 22635)
App minimum and target SDK version
- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [X] Windows 10, version 2004 (Build 19041)
- [ ] Windows 10, version 2104 (Build 20348)
- [ ] Windows 11, version 22H2 (Build 22000)
- [ ] Other (specify)
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
Version 17.8.2
Device form factor
No response
Additional context
When GC triggered, the frames update for about 0.5 sec, then it freezes again.
Help us help you
No, I'm unable to contribute a solution.
I get this problem with WinUI too, I've even tried the latest vNext version, and it still only captures for less than a couple seconds. It does occasionally update... maybe one frame every few minutes.
The UWP version works as expected.
This age-old WinUI 3 issue seems to remain unfixed and there are various related issues floating around:
https://github.com/microsoft/WindowsAppSDK/issues/2774https://github.com/microsoft/microsoft-ui-xaml/issues/4710This needs to be raised to the WinUI 3 team.
That's not a good news. I suspect this issue is related to memory reclamation. In my project, after calling gc.collect() every sec, the camera preview works perfectly. However, it raised serious performance problem.