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

Remove TCP Mode / Server #405

Closed
wants to merge 1 commit into from

Conversation

karlseguin
Copy link
Contributor

Websocket handler now interacts directly with cdp. Simplifies the flow by removing the websocket -> server hop.

I updated the submodule (hopefully correctly), to point to my own branch for lightpanda. I needed the afterInit working (alternatively, I also have this PR on lightpanda-io/websocket.zig

Websocket handler now interacts directly with cdp.
@karlseguin
Copy link
Contributor Author

Just learned about the demo project and the puppeteer tests there. Was looking at writing something like that..useful to have. Will look into these failures tomorrow.

@krichprollsch
Copy link
Member

Just learned about the demo project and the puppeteer tests there. Was looking at writing something like that..useful to have. Will look into these failures tomorrow.

I was writing a comment regarding that. Not sure why the tests are failing.

I started also lightpanda-io/websocket.zig#3 to zig fmt + add the check in the CI but the unit tests are failing now... IDK why GH didn't run these tests before.

@krichprollsch krichprollsch self-requested a review February 4, 2025 16:20
@francisbouvier
Copy link
Member

francisbouvier commented Feb 4, 2025

This approach removes entirely the JS loop (https://github.com/lightpanda-io/browser/blob/main/src/server.zig#L472). We need this loop to execute all JS async stuff (callbacks, setTimeout, etc).

That's why the current implementation has 2 infinite loops on 2 different threads:

  • one main thread with the Websocket loop (ws.listen)
  • one secondary thread with one loop mixing JS events and TCP events

I think we can still remove the TCP mode but we need to keep the JS infinite loop somewhere and create a way to communicate with the WS events (eg. stop the JS loop when the ws client closes the browser and start a new one afterwards with the updated new browser and v8 context).

@francisbouvier
Copy link
Member

Another solution is to have only one infinite event loop with both JS events and WS event (ie. in non-blocking mode). Either:

  • use the WS non-blocking event loop (which uses directly epoll/kqueue if I understrand well) on the JS part
  • or use the JS event loop (tigerbeetle one) on the WS part

I think that's more work than having 2 threads with 2 infinite loop, that's why I did not go on this path.

@karlseguin karlseguin closed this Feb 5, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants