AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.58k stars 2.22k forks source link

XAML previewer causes audio playback issues (and mouse stutter) #14795

Closed foglio1024 closed 7 months ago

foglio1024 commented 7 months ago

Describe the bug

When visualizing the XAML preview inside Visual Studio 2022, any playing audio (e.g. browser, Spotify, etc.) crackles and stutters. This becomes more severe when using low latency ASIO audio drivers for external audio interfaces.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Avalonia C# Project targeting Desktop.
  2. In any view or window, add a StackPanel with some Buttons inside.
  3. Build the project to enable the preview.
  4. While playing audio, zoom in the preview and move the mouse over the buttons.
  5. Audio crackling should be noticeable during mouse movements, to the point it becomes distorted and robotic in most severe cases.
  6. Mouse movements show some stuttering too.

Expected behavior

Interacting with the live preview should not affect audio playback or mouse movements.

Screenshots

YouTube video demonstrating the issue happening even with the most possible audio samples (1024) and therefore the most audio driver stability (this is usually kept as low as possible for low latency applications though). The audio issue is very noticeable towards the end of the clip. The mouse movement issue is less visible, but it should be noticeable with a close look.

Environment

Additional context

More complex layouts with running animations can cause the issue even without zooming in or interacting with the previewer.

kekekeks commented 7 months ago

Seems to be a CPU performance problem with your machine, since previewer doesn't interact with GPU and audio APIs in any way. It's just a background process that sends SW-rendered frames over a socket to our visual studio plugin.