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

choppy audio (synchronization API?): a reproducible way to max out one core on XPSP3 by just displaying a page #612

Open
JoachimHenze opened this issue May 22, 2024 · 27 comments
Labels
bug Something isn't working

Comments

@JoachimHenze
Copy link

JoachimHenze commented May 22, 2024

Describe the bug
One CPU core is maxed out, and therefore the audio-playback will start to blubber. I do suspect a bug in the synchronization API of progwrp.dll

"Supermium 122.0.6261.152 (R6) x86" is affected in both cases on WinXPSP3:

  • when using the stock-shipped progwrp 1.1.0.5012.
  • And also when using @IDA-RE-things latest version 1.2.0.5054

To Reproduce
Go to the following podcast site: https://apolut.net/noch-eine-pandemieinszenierung-von-felix-feistel

On XPSP3 x86: As soon as that site is loaded, even if the video does not play yet, one CPU is constantly maxed out. This happens also when just idling at this site (without playing any content). It happens also if you decide to start playing the video. And it even happens if you click the 2nd tab on the right side, which allows to play only audio but no video.
host is XPSP3 Professional, Intel Pentium E5200 Wolfdale 45nm "C2D-based", 2 x 2.5GHz (no Hyperthreading, real cores), 4GB RAM, Ati Radeon HD4350

If I do try the same scenario with the x86 browser on Win8.1x64 on similarly-powerful HW, the bug does not happen.
In all cases, when just idling at the site, when playing the video, or when playing just the audio, on Win8.1 the CPU-load remains in the range of 0-3%. With the same browser version.

Therefore I do suspect a major inefficiency, or even a bug in the synchronization API provided by progwrp.dll.

Please have a look into that, I do suspect that solving this may greatly benefit the browsers ability to play audio and video on XPSP3.

@JoachimHenze JoachimHenze added the bug Something isn't working label May 22, 2024
@JoachimHenze JoachimHenze changed the title choppy audio, synchronization API, a reproducible way to max out one core on XPSP3 by just displaying a page choppy audio (synchronization API?): a reproducible way to max out one core on XPSP3 by just displaying a page May 22, 2024
@JoachimHenze
Copy link
Author

The 1-core-max-CPU-load returns to normal level in this usecase/symptom, as soon as I close this specific tab.

Which function is frequently called, when that tab is open on XPSP3?

@XakerTwo
Copy link

XakerTwo commented May 22, 2024

on my host machine this site utilize one of 4 cores. According to fast inspection it's issue with site visual(NoScript in most strict mode does not help). To be more preciese the issue in "Unterstützen" red button that has .pulse-button class with infinite animation. If you has something like Style-bot you probably can fix it by this small rule. (Try and reply does it helps or not)

header.head-main .pulse-button { animation: none !important; }

Rule above will disable animation only for .pulse-button in header, if you wish disable it on all such buttons on this site - use this

.pulse-button { animation: none !important; }

If you don't have such extension i can recommend something like oiaejidbmkiecgbjeifoejpgmdaleoha (support css only) or nbhcbdghjpllgmfilhnhkllmkecfmpld (support css and js)

UPD:
Also more fast check can be performed by deleting this button from elemnts tree in DevTools

  • Open site
  • Press F12 - devtools appear
  • Press Ctrl+Shift+C - now elements uder cursor should highlights, it also may increase CPU usage even more
  • Hover and click on red button - now it should be selected in elements tree on Elements tab
  • Press Delete button - button should disappear from tree and on page
  • Check CPU consumption, if it returns to normal - rulesabove will helps

@JoachimHenze
Copy link
Author

JoachimHenze commented May 22, 2024

Thank you for the suggested workaround (I did use the devtools-one without 3rd party plugin). I do confirm that when I do exclude the pulse-button on XPSP3 like that, then the high CPU-load is gone. With this trick I can play the still-frame-"video" smoothly, and I can also listen to just the audio smoothly without stuttering. CPU% is nailed to 0% then.

Why isn't this a problem when running the browser on Win8.1x64 ?
Is any of our synchronization stuff in progwrp causing any massive overhead when "handling the pulse button" on XPSP3?

@XakerTwo
Copy link

Rly don't know why it different for Win8.1 probably some optimizations by browser, but it happens as well on Win 7 SP1. And it's due to CSS animations always works on CPU and probably in the page thread (such things is awful in terms of parallelization)

@JoachimHenze
Copy link
Author

maybe @IDA-RE-things can say why this use-case hurts XPSP3 and Win7 so much more. Maybe he can say, what would need to be optimized?

@JoachimHenze
Copy link
Author

I benched regular Chrome v49 (last native XP version without progwrp.dll): The CPU-load is ~25% with that (one core is used to 50%). Still the pulse-button is rendering fine.

With "Supermium 122.0.6261.152 (R6) x86" the CPU-load is 50% to the brim (one core is used to 100%).

@IDA-RE-things
Copy link

I have done some small investigation for that problem:

  1. Yes, CPU utilization is so high even when video not playing, because of animated button. And w/o HW acceleration of rendering on XP.
  2. The audio glitches gone if I "minimize" window, so it not active and not visble, but playing that video.
  3. The audio glitshes is because of rendering of frame has so much time w/o acceleration and because of software rendering again (I think)
  4. and in my oppinion its not depends on synchronization code of progwrp (stock or my). It depends on code that uses synchronization API (inside other browser code).

btw, the stock dll has ver 1.1, not 1.2, (to prevent confusion) .

@win32ss
Copy link
Owner

win32ss commented May 23, 2024

If it affects 7, then it would not be the synchronization API implementation in progwrp, as whatever progwrp implements was mostly implemented in Vista.

But yes I can confirm that a whole thread on my Xeon E5-2667 v2 is being used in a GPU process on the page above, on XP x64. When d3dcompiler_47.dll is patched to run on XP x64, the CPU usage gets cuts in half. 8.1 is actually in a similar situation (both running in VMware WS 12), but it defaults to having GPU acceleration available.

So the issue is partially that of a lack of GPU acceleration. On XP x64 however, the GPU acceleration quickly fails, forcing a fallback to a non-accelerated state. I will work to stabilize the GPU acceleration.

Even on Superfox 127 on 8.1, CPU usage increased considerably when that page was active.

@Stepman123
Copy link

On XPSP3 x86: As soon as that site is loaded, even if the video does not play yet, one CPU is constantly maxed out. This happens also when just idling at this site (without playing any content).

This problem is related to the lack of GPU acceleration. High CPU load could also occur in Windows 8 if your graphics card did not support acceleration. Additionally, the reason lies in Chromium itself, version 122. For example, version 109 on this website loads 30% CPU, while 122 loads 60-100% CPU. MyPal68 1-2% (Pentium-4 socket-478; GPU 9600 OpenGL 2.1, GLSL 1.20)

@Stepman123
Copy link

3. The audio glitshes is because of rendering of frame has so much time w/o acceleration and because of software rendering again (I think)

Since I have Windows 7, acceleration does not work either, but the sound works fine, even if the CPU load reaches 100%. So obviously the problem lies somewhere in the API for thread-sound prioritization, which is not supported in XP/2003.

@win32ss
Copy link
Owner

win32ss commented May 23, 2024

I also noticed low CPU usage in MyPal 68 even with hardware acceleration disabled, which beats the Chromium browsers and newer Firefox. So maybe the real issue is a massive lack of efficiency in the Viz compositor.

And Vista and up use WASAPI instead of wave audio for audio input/output by default.

@XakerTwo
Copy link

As for me it's normal situation that you have any lags and freezes on high CPU usage and that the css with such animations cause high CPU usage.

Also

  • HW accel is enabled for me
  • Seems i lied a bit when said it utilize one core - i made such suggestion based on total CPU load, that jumps between 14-25%. Looking at cores usage i don't see any core was fully loaded, but summary usage of all cores yes up to 25%, when w/o animation about 3-6%. btw GPU usage about 6% but i'm sure it's not related to animation itself

Animations as i know works on CPU entirely (all that not related to complex gfx)
Animation ask for new frame until ends, when it infinite it will ask each tick while page visible, so tab switching also drops the CPU load

Looking at what they(site) animates - it's a box-shadow... one of the most expensive attribute especially for transitioning and animation, it's also 2D which usually computes on CPU, even with HW accel. For me it's purely site issue. So working with a "file" (tool) is already the norm for me 😄

for example check this one codeped.io - there Start Coding button in the left top corner with infinite animation when HOVERED. load slightly lower but also behave in same manner

@JoachimHenze
Copy link
Author

JoachimHenze commented May 23, 2024

When d3dcompiler_47.dll is patched to run on XP x64, the CPU usage gets cuts in half

Is there any tutorial how to get that? Would it work on x86 XPSP3 as well? Will it be included in any of the next versions?
Thank you all for your shared thoughts and analysis. I will just wait and watch here now.

@IDA-RE-things
Copy link

I'm also working on such D3DCompiler dll, to provide not only working, but also smaller and faster alternative for x86 XP for the browser.

@win32ss
Copy link
Owner

win32ss commented May 24, 2024

When d3dcompiler_47.dll is patched to run on XP x64, the CPU usage gets cuts in half

Is there any tutorial how to get that? Would it work on x86 XPSP3 as well? Will it be included in any of the next versions? Thank you all for your shared thoughts and analysis. I will just wait and watch here now.

My iteration will work on XP SP3 as well and ultimately all Supermium target platforms and should be ready for the next release in the middle of June.

@IDA-RE-things
Copy link

@JoachimHenze , are my solution works for your ? It works for me on that test page and on youtube. And someone will steal ideas of course.

@Stepman123
Copy link

@IDA-RE-things

Thanks, it works. Can you port this to another browser? For example in Thorium 109-legacy-win7, 360EE 13.5?
Or directly into the One Core API?

@win32ss
Copy link
Owner

win32ss commented May 30, 2024

This is my own version of progwrp.dll with an updated SRW lock implementation. I am not planning on keyed event usage because not all Supermium target platforms support them.

progwrp_srw_test.zip

@IDA-RE-things
Copy link

Seems another variant of SRW also works good, approximately same as previous.

Maybe it makes sense to fix other bugs/problems that exist in the browser? "single-process" mode etc.
Can you add more labels to issues to filter them by category ?, as it was proposed in #610. Because now it disorder and heap.

@JoachimHenze
Copy link
Author

JoachimHenze commented May 30, 2024

@IDA-RE-things you are a god!
You fixed all my urgent problems in the browser now with your most recent progwrp fixes!
I tested your most recent 1.2.0.5059_withHWacceleration_build.
progwrp.dll identifies itself as 1.2.0.5058, and I switched to your recommended cmdline args to enable 3d accel on XP:
-use-angle=d3d9 --ignore-gpu-blocklist

My full command line currently:
C:\Programme\Supermium\chrome.exe --disable-remote-fonts --disable-alternate-ds --safebrowsing-disable-download-protection --in-process-gpu --use-angle=d3d9 --ignore-gpu-blocklist --compact-ui --disable-features=ChromeLabs,DownloadBubble --disable-sharing-hub

The result is breathtakenly good on my XPSP3 with my Radeon 4350.
It's not only the CPU load that dropped on my sample page https://apolut.net/noch-eine-pandemieinszenierung-von-felix-feistel from one core being maxed out, to now just 10-15% load for the pulse button. No audio stuttering anymore.
No audio stuttering anymore also when playing audio somewhere and then continue navigating the page.

I not even have any audio stuttering now anymore when playing youtube!
youtube videos, that in the past did not even were stutter-free even with 144p (no zero, no typo!), I can now play fluidly even with 720p60frames like the SpringDoorStopper-Testvideo https://www.youtube.com/watch?v=5VGLPP70Xtw
I do really love that state. You really just allowed the Windows XP to exist for another 25 years to come.

Really awesome work! The browser feels almost perfect now to me! I don't need any 2nd browser now anymore as a backup for the "special usecases". 100% Supermium now for me on all my devices.

This ticket is definitely resolved now, and I do close this report. Thousand thanks!
image

@JoachimHenze
Copy link
Author

For the record: I tested also progwrp_srw_test.zip v1.1.0.5015 but that does not help me with the pulse button. It still maxes out one core with that, and also has no HW acceleration. Audio is also still choppy with that.
So @IDA-RE-things solution in v1.2.0.5059 works a lot better for me.

@XakerTwo
Copy link

just thinking out loud...

... I tested also solution by repo author but that does not help me with the pulse button ...

then probably you should left this issue open until repo author will not fix it or embed working solution?.. right now is just a mod and not "certified" fix. Moreover it's important issue for this browser and not a another 5px nor puzzle icon issue

@JoachimHenze
Copy link
Author

Ok, reopened for that reason.

@JoachimHenze JoachimHenze reopened this May 31, 2024
@IDA-RE-things
Copy link

IDA-RE-things commented May 31, 2024

So we will compete in solving of problems? He will jut copy my solution in that case. 1st, 2nd, 3rd. Why ? Why not start solving other bugs? All will be happy. Because its XP- and weak-hardware -specific issue here.

@IDA-RE-things
Copy link

I used to think that we were a team. When I first came here. But it turned out that it was not, over time. We are separate Competitors for success. Its not a ReactOS team. Are you have closed source components in ReactOS ? I think no. My name is nowhere in the coauthors, collaborators etc. Its project by one person only. Where one wish to take ideas and to create their "releases" with it. So how can we live with it ? So I started that separate "mod", because why I should help for that ? And then wait 1 month while it will be released or fixed. While owner is parteon-sponsored, and others (who they are? --no one) - no, And apply success to repo owner. Who even dont want to add labels to issues to simplify the search by category. No, thanks.

@docrR
Copy link
Collaborator

docrR commented Jun 3, 2024

I used to think that we were a team. When I first came here. But it turned out that it was not, over time. We are separate Competitors for success. Its not a ReactOS team. Are you have closed source components in ReactOS ? I think no. My name is nowhere in the coauthors, collaborators etc. Its project by one person only. Where one wish to take ideas and to create their "releases" with it. So how can we live with it ? So I started that separate "mod", because why I should help for that ? And then wait 1 month while it will be released or fixed. While owner is parteon-sponsored, and others (who they are? --no one) - no, And apply success to repo owner. Who even dont want to add labels to issues to simplify the search by category. No, thanks.

Keep such unsubstantiated and defamatory statements to yourself.

ReactOS is not Supermium, and Supermium is not ReactOS. Comparing very different projects, with very different objectives is not appropriate. A developer reserves the creative freedom to license their application as they see fit. Supermium takes a hybrid approach. It uses open source Chromium, adheres to its BSD philosophy, and just about all shell and feature changes should be port-able to other projects. progwrp, meanwhile, is not open source. This entire project, counting Supermium + progwrp (not to get into a GNU + Linux debacle) is arguably developed at a loss. Even if some profit is generated, it does not substantiate the level of intellectual labour poured into it. To raise an issue with the developer generating anything from it is extremely arrogant and narrow sighted.

Cordially,

@IDA-RE-things
Copy link

IDA-RE-things commented Jun 3, 2024

Ok. Where unsubstantiated and defamatory ? I mean is ReactOS for example, uses the way, where one of the main developers uses own closed source component, because he dont want to share his knowledge/knowhow with other developers ? Are this team in such case? No. Its a competitors in such case. He wants to be one person. Only one. All others -- ReactOS, WinE, One-Core-API etc, and other solutions, and I personally, are competitors for his solution it and for him personally. Are not ?

And I retry : I used to think that we were the team in current or on future, Share our knowladge and do co-working for projects. when I started to help. How team is defined? Where is "we" ? No, only one person. I mean developers. Or why no other developers here ? Why they dont want to join ? Who is LSC, (Corporation ?) Where Corporation ? One-developer-person corporation ?

Why he dont placed issue to comments in code for reference to discussions? Then Alex, Thorium main dev, takes them as patches, and prepares own release for that feature, not mantioned onyonw except repo owner. It was with latest "feature" about large picture size crash. I helped for that ? And it was not fixed actually. What is this ? And it only one. Im also wanted to place my small "footprint" in one of chromium clones, when I have seen its requered; as developer, or QA engineer, or project manager ; To provide my experience here and to help, and its why I have joined here early.
Or have other profits/benefits.

And I have read this recently :
https://www.patreon.com/posts/thank-you-to-all-103469621
Is it "is arguably developed at a loss" ?
So we and I are help for this ? And I personally over time with suggestions or bugreports; suggestions how to fix them. Much thanks ......

PS: And another one -- why he privatized the Microsoft brand "Win32" in his todays 22 y.o. ? Why I should see this in my Visual Studio and anywhere else avery time I want to develop anything ? What is this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants