-
Notifications
You must be signed in to change notification settings - Fork 2
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
[WIP] Enable having multiple browser tabs with a single node js and (headless) chrome instance #13
base: main
Are you sure you want to change the base?
Conversation
Hey Michael, I think that it is super cool that you use MagicMouse and want to improve it!! I can imagine that it is not easy to navigate the poorly documented code I have written and the binary protocol used to communicate to the Node.js script. Feel free to reach out whenever you have any questions or want additional feedback!
I see, makes sense! The only potential problem I am seeing is that I am not sure whether Puppeteer supports video streaming of multiple tabs at the same time. Have you tried that yet? By the way, in case you haven't seen that yet, I had to patch Puppeteer to add support for video recoding via https://github.com/cmfcmf/MagicMouse/blob/d5e6c260877c204d22e1a69a6e75a82d91ea5fb9/patches/puppeteer-core+1.19.0.patch. We're also using a super old version of Puppeteer, but I am not sure if there would be any benefits from upgrading to the latest version (and re-applying the video recording patch to it).
One interesting thing that you might not be aware of that I learned recently regarding Chrome's startup behavior: If you start Chrome, and then start another instance of Chrome, the second instance will just exit and delegate the new tab creation to the first instance, so there should not be any difference to just opening another tab. HOWEVER, I am not sure if the same behavior applies when controlling Chrome via Puppeteer, so you could still see the performance improvements you mention in that case. Regardless of that, running only a single instance of the Node.js script and Puppeteer will definitely be an improvement!
Sounds good!
👍
👍 If you want to get extra fancy, you could also consider to start a 30 second (just a random number I came up with) timer in Squeak once the last browser closes and only then shut down the browser and Node.js script. This would mean that the browser does not immediately shut down completely if you have no browser open in Squeak or minimize a Squeak MMBrowser window for just a short time.
👍
This sounds like a good sue case for the
No worries -- I am really excited to see a demo whenever it is ready!!
Sounds good! It would be amazing if you added the |
Hohoho @cmfcmf, I wish you a happy christmas time 🎄. Sorry for the late response. I had to a lot of other stuff 😅. Thanks for your detailed answer.
That is actually a very good point you bring up here. I just tried out whether this is possible and luckily it is (with a little restriction).
When In run this in
I think updating puppeteer is not needed as the current version works perfectly fine for me :)
Using the code above slightly modified I was able to test this. The result is that I can see two running processes of headless chrome instances in my htop (Which then each start a few more). Thus this behaviour seems not to kick in in case of using puppeteer with a headless chrome. I did not test this in
In my opinion a minimized browser would still count as opened. The timer idea sound nice 👍.
Thanks for the suggestion. I'll take a look at the class. |
No worries, I didn't really expect you to work over the holidays! And as you see, I also sometimes take a few days to respond :)
I see, good to know! I suppose it could be possible to open multiple windows instead of tabs in non-headless mode. I wonder whether that would allow to record the screen of multiple tabs in parallel. However, as you might have guessed, the non-headless mode really only is most useful for debugging, so that should be fine regardless.
Good to know! |
Nice example page by the way 👍 |
combine yarn commands; remove unused dependecies; adjust eslint rules
- Includes fix for out stream being stuck sometimes
@cmfcmf I just cleaned up this pr. If you got some time to spare, I would be glad if you could review it. How it works: The high-level code changes of this pr:
What I tested on MacOS and what you could do to test this pr:
Currently know issues / bugs:
|
Hi @cmfcmf,
as you might have already heard I am currently working with you project. For my goals I want to have multiple instances of the browser morph open at the same time. While this is currently possible by having multiple instances of the node process and therefore also multiple chrome instance open at the same time, I wanted to do that with a single instance for the whole squeak image.
The benefits I hope to get are mainly performance reasons and that this might be the less RAM hungry approach (as each chrome instance is likely to eat a lot of RAM 🍽️ )
For that I did / want to do the following:
As you can see, there is still quite some stuff missing. So if you notice anything above that could be solved in a better way that my approach I described, please tell me :)
Note!:
This PR currently also includes changes not needed for the suggestion above as they are needed for my current project. These changes might not be a very clean but working solution. I will make sure to remove these changes before merging this pr. But I guess merging will not be anytime soon :)
reactOpenOn:
andconnect: aUrl throwTimeoutError: aBoolean
run.js
which is why the change count is a little higher than expected 😅