jlplenio / crude-twitch-viewer-bot

Send live viewers to Twitch, youtube and kick with this viewer bot software. The tool offers a user-friendly graphical interface. This program requires HTTP proxies.
GNU Affero General Public License v3.0
326 stars 91 forks source link

Events in chat and peak CPU usage, crashing instances #228

Closed MarsToyStore closed 5 months ago

MarsToyStore commented 6 months ago

Thank you for your tool. It is very useful. However, I've noticed a bug that hasn't been fixed, despite the different versions.

Please answer the following questions:

Describe the bug
When using connected accounts with tokens, polls / shoutouts / predictions / pinned messages cause a peak in CPU usage that crashes many instances until the event is finished. The issue is related to the display of a pop-up window at the top of the chat. As long as the pop-up does not disappear, the connected instances crash one after the other.

jlplenio commented 6 months ago

Thank you for your detailed problem report. I see two options:

  1. We can investigate if it's an issue with my tool, Playwright or Twitch. I suspect that bad javascript code in this event is driving up CPU usage and all instances spike simultaneously. So I could try to prevent it from executing.
  2. We can verify that this issue only occurs when the chat tab is open. In my current implementation, the chat tab must be open to chat. I am thinking about moving away from this method and using IRC directly. This would then work like the GitHub version, probably without spikes and with a separate IRC chat connection per instance. This way we could also have users appearing and participating in chat but not in the viewer count.

Both options would result in the instances not being able to participate in the events. I have no problem with that.

MarsToyStore commented 6 months ago

Thank you for your prompt reply.

I don't use the version with the chat tab (0.8), the problem predates the existence of chat implementation - 0.7 - (you can reproduce it in 0.6 KoFi).

I don't use token to take part in these Events, so I don't care if they can't participate in them.
Be careful though, when you investigate the problem, it may disable participation in raids (?), not sure but the Event tab looks like poll / prediction / shoutout / hype train Event, when launching a raid.

jnwright commented 6 months ago

@MarsToyStore interesting! raids stopped working for me recently; maybe this is related?

jlplenio commented 6 months ago

@jnwright @MarsToyStore In any CTVBot version that allows token usage, the chat window will be open. This is because in order for the user to appear in the chat list, the chat tab has to be open i.e. a websocket is open to the Twitch IRC chat. So I still see promise in having the chat tab closed, which should prevent the spikes?! and I handle the chat connection directly from the tool to IRC, without the detour through the browser chat window. Should be less resource intensive, we could have low-cost users appearing only in chat, the tool can read the chat more easily, with a stable connection to e.g. have artificial chatters backed by openai in the future.

MarsToyStore commented 6 months ago

@jlplenio I meant the implementation of the chat tab in CTVBot.
Your IRC solution will prevent users-bots from joining raids. It's not a good solution, isn't it?

We simply need to check and understand why events tabs such as polls or predictions which appear at the top of the chat tab on Twitch cause these spikes. Then fix it, if you have time. I'm not interested in using these bots for chatting, I mainly use them for raids.

darkstarworks commented 6 months ago

I have been thinking about doing the following, but haven't gotten to it yet:

A service like ChatGPT (or an alternative) is able to improve certain code, as long as you do it in sections. You could try feeding it part(s) and see what happens.

When nothing gained, you only lost a little time.

If you do attenmpt this, please share inputs and results respectively. Thank you and good luck.

On Sat, Dec 23, 2023, 13:11 ToyStore @.***> wrote:

@jlplenio https://github.com/jlplenio I meant the implementation of the chat tab in CTVBot. Your IRC solution will prevent users-bots from joining raids. It's not a good solution, isn't it?

We simply need to check and understand why events tabs such as polls or predictions which appear at the top of the chat tab on Twitch cause these spikes. Then fix it, if you have time. I'm not interested in using these bots for chatting, I mainly use them for raids.

— Reply to this email directly, view it on GitHub https://github.com/jlplenio/crude-twitch-viewer-bot/issues/228#issuecomment-1868281510, or unsubscribe https://github.com/notifications/unsubscribe-auth/BD4T76O77OXLO2INOTKUGGTYK3DAHAVCNFSM6AAAAABA3MFL7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGI4DCNJRGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jlplenio commented 6 months ago

@MarsToyStore So you assume that the spike also happens when the raid initiates and thus the instance are too busy to follow? I was unaware that raids are that important. I though having light-weight chat solution which lightens the cpu load of each instance would be more favorable.

@darkstarworks Even though my code is far from the best, the greatest challenge is fine-tuning multiple Playwright chrome instances and all eventualities that could cause instability, e.g. ram leakage or javascript usage spikes.

darkstarworks commented 6 months ago

Sorry for going offtopic, but a few years back I experimented with an app that ran on a VPS and that did hundreds of views with ease.

Did meanwhile things just became a lot more complicated? Or what is the reason for playwright?

On Sat, Dec 23, 2023, 16:10 jlplenio @.***> wrote:

@MarsToyStore https://github.com/MarsToyStore So you assume that the spike also happens when the raid initiate and thus the instance are too busy to follow? I was unaware that raids are that important. I though having light-weight chat solution which lightens the cpu load of each instance would be more favorable.

@darkstarworks https://github.com/darkstarworks Even though my code is far from the best, the greatest challenge is fine-tuning multiple Playwright chrome instances and all eventualities that could cause instability, e.g. ram leakage or javascript usage spikes.

— Reply to this email directly, view it on GitHub https://github.com/jlplenio/crude-twitch-viewer-bot/issues/228#issuecomment-1868312787, or unsubscribe https://github.com/notifications/unsubscribe-auth/BD4T76M7ST3EIVZRU4LYBWLYK3X7JAVCNFSM6AAAAABA3MFL7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGMYTENZYG4 . You are receiving this because you were mentioned.Message ID: @.***>

jlplenio commented 6 months ago

@darkstarworks Judging by the old repositories on GitHub, there were more efficient ways to create viewers. But AFAIK they were all "fixed" by Twitch. Playwright just automates real browsers, which is super hard to tell. Although resource intensive, this crude solution just works, has worked in the past, and will work in the future. Plus, we can use this technique on many websites.

@MarsToyStore Two question:

  1. Do you know if the raid popup causes spikes?
  2. Do you know if the instances that do not follow the raid are marked as bot-detected? 257629075-1265d52e-61f3-4bbc-a6dc-3e078d5285e2
MarsToyStore commented 6 months ago

The issue preventing accounts from joining raids seems recent. The problem I'm talking about - Event popups causing spikes - is an old one. Also, until a few weeks ago, it was possible for these account to join raid despite this bug. I am sure of that. So I don't think it's related to your first point.

However, I've noticed that now almost all my instances are "Bot detected" very quickly. It may be related. I don't know.

Nevertheless, I'd be very grateful if you could fix these event spikes as soon as possible. A such drop of viewer - due to the spikes crashing instances - as soon as there is a poll, a prediction, a shoutout command is really annoying. Raid is just a part of the current issue.

jlplenio commented 6 months ago

If bot detected is true, this instance cannot follow or accept chat rules. It would make sense that they wouldn't follow raids, either. This is my best guess — yet. I will troubleshoot it after the holidays by setting up my own stream and starting quizzes?! What's the most reliable way I can recreate the problem? I agree that the focus should be on these spikes first and raid problems second.

MarsToyStore commented 6 months ago

@jlplenio The procedure seems straightforward to me. Start a stream with at least 30 blue bots on KoFi version 0.7 or 0.8. Launch a poll. Write "/poll" with your stream account, and write the question you want, and the answers you want. Observe.

This also works with predictions, or the /shoutout command, etc.

jlplenio commented 6 months ago

Thank you for your patience. I tried my hand in fixing or at least reducing the spikes in the newest version: https://github.com/jlplenio/crude-twitch-viewer-bot/discussions/235 Thank you for the tutorial @MarsToyStore, I had never streamed before. Additional things I noticed during troubleshooting:

I still suspect that instances, that have the "bot detected" flag set to true in the debug menu, are those that don't follow raids.

Alexistexas9697 commented 6 months ago

It is really important that bots go to another publisher via raid. There is no need to write or follow the chat he goes to. Because I have approximately +200 instant natural viewers, with this bot I increase this number to +300 viewers by adding +100 more viewers. However, since I am using the free version (I am not using tokens for now), a maximum of 200 viewers participate in the raids. For streamers like me, these bots need to participate in raids with determination. In fact, such successful programs are used by streamers like me who have regular viewers. Someone who is new to the streaming business does not use such programs by paying a fee, they generally use intermediary sites. I'm waiting for you to fully handle this "raid" issue. Once you're fully successful, I'll switch to the paid version. You really do your job well, it makes me happy that you are so interested in your job. I hope you never quit this job, because we can boost ourselves by using it :)

Edit: I have one more question, I want to buy this special version for supporters with a subscription from Ko-Fi. When I buy this, I want to add this program to both my own computer and the remote server (since my own system is insufficient, I divide it between 50proxy and 50proxy and thus I can send +100 bots). Do I need to buy 2 different subscriptions for this? If so, paying €20 every month would make me very upset. I live in a country where the Euro is very valuable and it can be very difficult to afford it every month. :(

jlplenio commented 6 months ago

I still suspect that instances, that have the "bot detected" flag set to true in the debug menu, are those that don't follow raids.

  1. I can never guarantee that the raids will work as there are too many parts at play that I cannot control (tokens, user-agents, proxies) and then the instances will get flagged and won't follow raids. If everyhing is clean and fine, it shoud work.

  2. ko-fi is first and foremost a way to support and motivate me to improve the tool. Once you subscribe, you can download this version of the tool and keep it forever - it is not tied to kofi. It is not a problem if you cancel the subscription immediately if you do not have the resources.