Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add protocol.registerStreamProtocol #507
To land cleanly, that changeset requires other upstream changes to be ported:
bool Converter<const net::HttpResponseHeaders*>::FromV8
The good news is that muon compiles with the ported changes, and using a fork of ipfs-companion I'm able to "stream" a response from ipfs via muon to brave.
I should qualify that I'm pretty good at spelunking around in codebases and porting things that look like they might work, but I have little C++ experience, so I'm offering this up as a starting point for discussion as a fix for brave/browser-laptop#10629
Streaming works sensibly now thanks to @alanshaw
referenced this pull request
Feb 23, 2018
I've cleaned this up a little.
Likewise I have no experience with C so I can't really comment on that code. It could do with some
What's slightly bothering me atm is that the streaming works, but it doesn't support backpressure (notably neither does electron-ipc-stream). It means that if the destination starts saying "no more for now" we ignore it and keep pushing chunks through. I'm assuming that behind the scenes the extra chunks are buffered up until the destination is ready to receive again.
Pending the outcome on that we probably need to decide if that is a blocker or not. I'd like to register my preference to not block so we can get this landed and so people can start trying it out!
As an FYI, streaming bit works like this:
We need to stream data from the renderer process to the main process. To do this we create a "cross process through stream", which is writable on the renderer side and readable on the main process side. When data comes in to the writable side on the renderer, we use the IPC channel to pass it over the boundary. The readable on the other side picks it up and makes it available to whoever is reading it.
In the renderer we're just attaching a 'data' event handler to the stream provided by the protocol handler and firing off an IPC message for each event.
In the main process there's now a readable IPC stream which listens to the IPC messages and
Some other concerns:
We're sending chunks to the IPC channel in the order they arrive from the source stream. On the other side will they be fired as events in the same order? WE HAVE ASSUMED YES.
We added the tests from the electron PR but I couldn't figure out how to run them. Am I correct in saying that the tests aren't currently runnable in muon?