ButzYung / SystemAnimatorOnline

XR Animator, AI-based Full Body Motion Capture and Extended Reality (XR) solution, powered by System Animator Online
https://sao.animetheme.com/XR_Animator.html
852 stars 75 forks source link

When the app is not in focus, it will slow down. #60

Closed PeterJared closed 8 months ago

PeterJared commented 9 months ago

This means that if we select a different application, such as a game or a video conferencing app, XR Animator will significantly reduce CPU and GPU usage by drastically lowering the frame rate. This is a standard system in Unity designed to avoid using resources in a game when it is not in use.

However, in this application, we often stream animation from XR Animator while using another application, which can be problematic. Is it possible to disable this slowdown, as I believe can be done in both Unity and Unreal, or at least provide an option to choose whether the slowdown occurs or not? I think this app is great.

For me, the ability to use XR Animator simultaneously with other applications is a crucial feature.

Thanks!

ButzYung commented 9 months ago

This is a known issue under certain situations. You can either disable Windows "game mode" (which slows down background apps) or open task manager and give XR Animator a higher processing priority.

MioBlackHeart commented 9 months ago

I'm having this issue as well... Game mode doesn't seem to fix it and im on a 14900K at 6GHz. only 10% of my CPU is being utilized and the issue is happening.

PeterJared commented 9 months ago

From what I can see, the problem becomes evident if another app competes with XR Animator. For example:

What works, but obviously needs extra resources, is to use a second computer to run XR Animator and stream the animation over a local network. This is possible if you add the IP of the computer running the second application. Then, it is perfect and comfortable to use as performance will be stable. For example a laptop used for hosting the app with a 3070 is fine. If it is a desktop PC the card can be weaker as desktop PC graphic cards are more powerful. XR Animation performance is good having in mind how demanding is Media Pipe and this tech in general.

None of the workarounds from the second post work (e.g., game mode, etc.). At least in Windows 11. In Unreal, there is an option to keep the app always in focus. No idea about Unity.

MioBlackHeart commented 9 months ago

The program in use while XRA is running are vNyan, Games, Discord, and Web Browser. I notice the issue around version 19 of XRA. I should test the older version of XRA. (version 18). As older one didn't have this issue before.

PeterJared commented 9 months ago

How can I test the version 18?

MioBlackHeart commented 9 months ago

How can I test the version 18?

Download and see if it does the issue we both are having. I don't have time to test this week.

https://github.com/ButzYung/SystemAnimatorOnline/releases

PeterJared commented 9 months ago

Tested. The behaviour seems different. 19 is faster than 18. 18 does slowdown less when not in focus, but wont become a lot faster either then in focus. Then the result is a average slow behaviour in both cases, that I don't like With 19, when in focus is very smooth and when not in focus slower. But at least I can use both apps with full speed. 19 full speed is very nice when 18 full speed is annoying. Then I prefer behaviour of 19 as I don't think 18 is usable. I tried also to set priorities to real time, with little difference.

MioBlackHeart commented 9 months ago

Tested. The behaviour seems different. 19 is faster than 18. 18 does slowdown less when not in focus, but wont become a lot faster either then in focus. Then the result is a average slow behaviour in both cases, that I don't like With 19, when in focus is very smooth and when not in focus slower. But at least I can use both apps with full speed. 19 full speed is very nice when 18 full speed is annoying. Then I prefer behaviour of 19 as I don't think 18 is usable. I tried also to set priorities to real time, with little difference.

Yeh. give 17 a shot? Just trying to narrow the slow down issue.

PeterJared commented 8 months ago

After testing 17, basically 17 doesn't care if it is on focus or not, but it will give you the same performance. The problem is: 17:

19 and above:

As you can see 17 is more stable but you can get in certain circunstancies a lot more performance in 19. 22 fps is very nice and look nearly high quality capture, 12 feel cheap and sluggish , 6 is unusable.

Then, if you want stability, you need to accept a uniform cheap performance. If you want quality, you will be worry continuously who is on focus. The only workaround to that is to use a second computer in a local network to stream XR to the main PC. it works perfect but then you need 2 computers.

ButzYung commented 8 months ago

You can try moving the electron folder of v0.17.x to the latest version (v0.19.x), run the latest version of XR Animator using the moved version of electron and see if it makes any difference. Note that you will need to copy app.asar from the resources subfolder of the latest version of electron and replace the one from the older version of electron you want to run.

PeterJared commented 8 months ago

Hi, thanks for the hint. After trying, I yet get the same behaviour from 19 (that I prefer to 17) Meaning: 17: On focus: 12fps Not on focus 12fps

19 and above: On focus: 22fps Not on focus: 6fps (unless nothing is competing with the XR animator for the GPU)

ButzYung commented 8 months ago

Are you using a laptop? I suspect that v0.17 is running on your integrated (slower) GPU, while v0.19 is running on your dedicated (faster) GPU. A recent update in v0.19 enforces the use of faster GPU on laptop. This may explain why the performance on v0.17 is unaffected whether it's focus or not, because while integrated GPU is slower, it isn't competing resources with other apps most of the time.

Have you tried opening task manager and give XR Animator a higher processing priority?

PeterJared commented 8 months ago

I tested and you are right. I can see in the task manager what GPU each app is using and in 17 is using the integrated card and in 19 is using the main dedicated Nvidia card Its yet surprising that it can get 12 fps with a integrated card. And the dedicated card only gets 10fps more even is a lot more powerful and struggles when not in focus. I tried multiple times to use process priorities and did not work, in both XR and the other 3d ap. Also other friends tested it. It makes no difference as if it was designed for priorities for the CPU but not the GPU. The other app (the target for the VMC stream) doesn't care if it is on focus or not, even it can be setup to slowdown when not in focus in their options.

ButzYung commented 8 months ago

Just curious, how do you read the FPS info? Are you referring to those on the upper left of XR Animator?

PeterJared commented 8 months ago

Yes, they reflect quite well the real performance, many times is 24fps and I have I 4080 laptop, the equivalent to a 3080 desktop in terms of performance. But even in a 3070 laptop (I guess similar to a 2080 desktop) runs quite well at nearly the same speed. In general top body capture is a extremely good quality when conditions are correct.

ButzYung commented 8 months ago

There are multiple values of FPS on XR Animator. P-FPS is the one for body mocap. The front value is the actual FPS, which is technically capped at 30 and is usually slightly lower when system load is heavy. The one behind the slash is the processing FPS, which is often higher than the actual FPS. The last FPS value is the 3D display FPS of XR Animator. For your GPU you should expect 60fps all the time (when in focus).

When used alone, the system requirement of XR Animator is actually quite low. Most of my demos were run on just a GTX1650 GPU, and the FPS is pretty maxed most of the time.

PeterJared commented 8 months ago

image This is what I get when the app runs alone and with a competing app and not on focus (on focus will run ok with competing app) I place more attention to the P and F lines instead the last one as it reflects better the real performance. image

PeterJared commented 8 months ago

I just noticed, if my integrated laptop graphic card runs at 12fps, how fast will run in my laptop that only has integrate card? Its a faster integrated card as it is the only one in the system, a Intel Iris Xe Graphics G7. It runs faster than 20, nearly the same than the desktop one. The laptop with only integrated card is a The Samsung Galaxy Book Pro 360 2

MioBlackHeart commented 8 months ago

@PeterJared That's a spec issue for your FPS. I'm running i9 14900K w/ 2070RTX

Version 19.6 I tested 17.5 and 18. They're all having the FPS speed. Version 18 seem to have the slowdown issue as well when i don't have the program in front. 17.5 doesn't seem to have that issue for me. (yet) *They been given "High" Priority in task manager.

2024-02-20 08_33_06-Window

PeterJared commented 8 months ago

My card is faster than yours, not sure why it runs faster for you , FPS etc I will check with other people what speeds they get

MioBlackHeart commented 8 months ago

My card is faster than yours, not sure why it runs faster for you , FPS etc I will check with other people what speeds they get

you do realize I'm on 1920 x 1080 right? I'm getting like 30/95 P-FPS | 30/85 F-FPS at one point. if i match your resolution. its surely would goes 2x the amount. but regardless the FPS: still hitting 60 which i assume is the cap limit so that really doesn't matter.

What I wanna know and the topic seem to be steering off course, We're trying to resolve the issue with the drop in performance when the program isn't in focus after some period of time. bring the application in front again will resolve that issue but that's only a temp fix until it does it again after not being in focus.

PeterJared commented 8 months ago

Obviously, the difference in speed is peculiar. This suggests that there are factors beyond computer specs affecting FPS. It could only be due to:

PeterJared commented 8 months ago

I solved assigning the app to the second graphic card. Being a laptop, is weaker than the main one, but enough to run XR Animator in a Ok stable speed. Certainly a better experience than using old versions of the app or competing the GPU with other apps.