carcabot / tiktok-signature

Generate tiktok signature token using node
734 stars 285 forks source link

playwright cpu usage high #64

Closed LSeiei closed 4 years ago

LSeiei commented 4 years ago

After using playwright, the cpu usage of '/root/.cache/ms-/webkit-1219/minibrowser-wpe/WPEWebProcess' has been very high

image

carcabot commented 4 years ago

I'm trying to find an explanation for this cpu usage... it's very high

carcabot commented 4 years ago

@LSeiei can you change url from this line with a user profile or something less animated.

for example: https://www.tiktok.com/@rihanna

Let me know if you still get 100% cpu usage.

Greetings.

jonas-meng commented 4 years ago

@LSeiei can you change url from this line with a user profile or something less animated.

for example: https://www.tiktok.com/@rihanna

Let me know if you still get 100% cpu usage.

Greetings.

tested with less animated launch page, CPU usage drops

mvillalba commented 4 years ago

I'm running into this too. Playwright effectively just pins one core to nearly 100% usage. It never really drops. It's worse on live environment for my program as the VPS only has 1 vCPU.

Would it be possible to: 1) Target a less demanding page on startup, like you mention above. 2) Spin down the browser if unused for 5 minutes? Then check and start another Signer as needed on demand

I could do this myself for my project and fork it, but I'd rather not have to maintain a fork.

If the original dev isn't available, I could do this myself and send a pull request. Would this be a welcome change, @carcabot ?

Cheers

carcabot commented 4 years ago

@mvillalba The target startup page cannot be anything, it should contain all scripts and functions required by signature generator.

About CPU usage, on OS X I don't have any issues, instead on a Debian VPS it stays at 8% with this startup page https://www.tiktok.com/@rihanna and at 100% with default startup page.

This is definitely a issue with playwright and webkit and I cannot find an explanation why is using too much cpu.

If you don't have to generate multiple signatures in a short time, you can easily use CLI to generate signature instead server.

You can whenever to do a PR, I will be happy to review it.

Greetings.

yoavz commented 4 years ago

Just to add a bit more flavor to this discussion, I'm finding much better performance (somewhere around 5% CPU usage on my macbook) switching over to Chromium backend for Playwright and adding these arguments:

+      args: [
+          '--no-sandbox',
+          '--disable-setuid-sandbox',
+          '--disable-dev-shm-usage',
+          '--disable-accelerated-2d-canvas',
+          '--no-first-run',
+          '--no-zygote',
+          '--single-process', // <- this one doesn't works in Windows
+          '--disable-gpu'
+      ],

Here is how I'm doing it on my fork: https://github.com/yoavz/tiktok-signature/commit/65fa9aeb858ee1dc8d10887ab4d1332b995cfc18. I've introduced probably too many API changes to upstream it back in a PR, but if anybody wants to cherry-pick it feel free.

maxrexfax commented 9 months ago

ksnip_20231226-171413 ksnip_20231226-171353 Every start of playwright tests causes 100% CPU load. Is it fault of some media on target site or something else?