Solitaire icon indicating copy to clipboard operation
Solitaire copied to clipboard

Infinite animation causes high CPU usage

Open stevemonaco opened this issue 8 months ago • 4 comments

Forgot to report for tracking. This is the only animation in the app and the effect is pretty subtle.

https://github.com/AvaloniaUI/Solitaire/blob/8f5a3713c9100faf49e13dc3919420706835e3df/Solitaire/Styles/TrayContainer.axaml#L51-L67

stevemonaco avatar Apr 12 '25 21:04 stevemonaco

From the discussion on the telegram, does it seem like this animation actually improves general smoothness of the app? By forcing render each frame.

maxkatz6 avatar Apr 17 '25 04:04 maxkatz6

I can't really tell any smoothness difference here during intense animation (dealing). The Solitaire app itself doesn't have much in the form of interactive UI elements (eg. even the buttons don't have :pointerover effects) so there isn't anything that needs to quickly wake up.

This is with package updates to 11.3.0-beta2, publish -c Release + dotnet serve, and on a 60fps display using Edge (Windows).

stevemonaco avatar Apr 17 '25 04:04 stevemonaco

It might be multithreading specific problem

maxkatz6 avatar Apr 17 '25 04:04 maxkatz6

I'm working on my own MT WASM app and came across this again. Single thread worked fine, MT would pause about a full second before a pointerover color change started.

Instead of using an infinite animation, I seem to be able to fix it with:

var options = new BrowserPlatformOptions()
{
    PreferManagedThreadDispatcher = false
};

stevemonaco avatar Aug 29 '25 19:08 stevemonaco