Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% CPU usage on particular windows PC in v11.1.0 and up #17555

Open
philfontaine opened this issue Nov 19, 2024 · 3 comments
Open

100% CPU usage on particular windows PC in v11.1.0 and up #17555

philfontaine opened this issue Nov 19, 2024 · 3 comments

Comments

@philfontaine
Copy link

Describe the bug

The render thread is always at 100% CPU usage, even in Idle. This only happens on a windows PC at my work, and only happens on 11.1 and 11.2

11.0 works fine

Since this bug is probably not reproducible easily, I will include a dotTrace snapshot.

Turns out the dotTrace apps also use Avalonia v11.1 and therefore have the same bug (see screenshot below).

Let me know if there is anything else I can provide to help find the issue.

To Reproduce

  • Create the most basic avalonia app using the default template
  • Run the app

Expected behavior

The CPU usage is close to zero when the app is idle

Avalonia version

11.1, 11.2

OS

Windows

Additional context

image
image
image
image
image
image

AvaloniaApplication1 - [2024-11-18 20-54-13].zip

@philfontaine philfontaine changed the title High CPU usage on particular windows PC in v11.1.0 and up 100% CPU usage on particular windows PC in v11.1.0 and up Nov 19, 2024
@philfontaine
Copy link
Author

I'm also including screenshots and a snapshot for the same basic app but with v11.0.13

image

AvaloniaApplication1 - [2024-11-18 21-33-24] 11.0.13.dtt.zip

@maxkatz6
Copy link
Member

Do you have any suspicious logs in the app? Or any exceptions, if you enable handling of all unhandled exceptions in debugger?
It could be a rendering device being lost after each frame, which would cause recreation of render target:

if (_backend == null || _gpuContext?.Value.IsLost == true)
{
_backend?.Dispose();
_backend = null;
if (_gpuContext != null)
{
_gpuContext?.Dispose();
_gpuContext = null;
ContextDisposed?.Invoke();
}
if (_graphics != null)
{
if (_readyStateFeature?.UsesContexts != false)
{
if (_graphics.UsesSharedContext)
_gpuContext =
new OwnedDisposable<IPlatformGraphicsContext>(_graphics.GetSharedContext(), false);
else
_gpuContext = new OwnedDisposable<IPlatformGraphicsContext>(_graphics.CreateContext(), true);
}
}
_backend = AvaloniaLocator.Current.GetRequiredService<IPlatformRenderInterface>()
.CreateBackendContext(_gpuContext?.Value);
ContextCreated?.Invoke(_backend);
}

@philfontaine
Copy link
Author

I ran the debugger, and nothing seems out of the ordinary (no exceptions or logs)

What I really believe is happening is that there is no pause whatsoever in the render loop, so the CPU is running at 100%.

I took another snapshot but with call counts, and it seems to confirm my theory since there are hundreds of thousands of calls in just a few seconds.

image

I also took a snapshot of the same app on v11.0.13 and the call counts are more reasonable (few hundreds)

image

AvaloniaApplication1 - [2024-11-19 08-40-54] v11.2 Call counts.dtp.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants