-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add javascript signalling #88
Add javascript signalling #88
Conversation
a608292
to
2ffad41
Compare
Whee, that looks very interesting, I'll review as soon as I find time :) |
Can you expand on the commit message for "message: Add message routers and handlers ", explaining why this is actually needed? The code looks fine but I can't quite understand the intent behind it :) |
I know this wasn't the case before, but I think you will want to also add the posting of progress messages to The start method was already blocking while waiting for cef initialization, which isn't great without posting progress messages, but if we now also (optionally) wait for an arbitrary amount of time for the web page to reach a certain state it becomes even more critical to post these :) You should notice the difference in behavior with gst-launch after the messages are added. |
Sorry for not reviewing earlier ! This looks very useful to me, though admittedly not entirely generic, I'm OK with merging once my comments are addressed :) |
I toyed with allowing the user to send all gstreamer events from javascript, but then I'm not sure there is an event that correlates to the "ready" signal I add here. If you can think of a way of making this more flexible / generic, then I'd be happy to improve the API. |
No, I think that's fine for now :) |
Is there a reason |
Oh hrm wait, this question makes me realize you're probably piggy-backing the wrong mechanism :) |
cef status is global, it tracks whether cef needs to be deinitialized (because all browsers / cef sources are done rendering). |
Yeah. |
Here you want a separate, per source additional mechanism to wait for readiness, you can probably mirror the existing one |
Should I use the |
Yes, that seems appropriate |
bf1a987
to
7a5b8bf
Compare
Can you squash the following commits together:
? Re progress messages, that is not what I meant, here is an example: |
So replace where I've added GST_DEBUG_OBJECT calls with your GST_ELEMENT_PROGRESS macro? |
7a5b8bf
to
6fe7d23
Compare
Define message handlers for the render and browser processes (to enable inter-process communication - see https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-inter-process-communication-ipc). In short this allows us to send messages from js to C++ in the main "browser" process of cef. The two functions ("gstSendMsg" and "gsCancelMsg") are attached to the javascript global "window" object. Note that we need to add a RendererApp in this commit to contain and run the javascript side of the message routing. See cef sample for more detail: https://github.com/chromiumembedded/cef-project/tree/aaccb78661c390a5ce6650df8db54ea5424d431c/examples/message_router
See the sample in the html/ directory for an example usage. This should be useful for those webpages that have non-trivial load times (webgl apps, etc) - allowing the page to signal from javascript to the gst pipeline that the page is ready for display. We can also send an EOS signal to be turned into an event on cefsrc. Flag for enabling this feature is listen-for-js-signals, and then on the javascript side you can send signals (see html sample for detail): window.gstSendMsg({ request: "ready" | "eos", ...})
4eb1feb
to
c4f59c8
Compare
btw. Thanks for the patch. |
I'm getting a seg fault when starting another pipeline with a cefsrc in after the first cefsrc has emmited the eos due to the javascript |
Managed to trick the loader to load the debug version - this is what's failing:
@MathieuDuponchelle - do you have any ideas? It looks like I'm not shutting things down properly (the cef_status goes to SHUTDOWN after the eos, so I'm not sure where the cleanup is broken). |
ouch, I don't have an idea right now no |
can you post a test case? |
I don't have a gst-launch command that allows for this behaviour. Let me see if I can make a simplified version of our application to replicate. But the basic idea is:
|
OK, yes please make a reproducer application so I can take a look on my end, otherwise I'm afraid we'll have to revert this until we come with a fix for the issue :) |
@MathieuDuponchelle - my colleague set up a repro example last night - I think this is a bug that pre-existed this signals work. See https://github.com/aiden-jeffrey/test-cefsrc for the sample. There's two in there. I managed to repro the segfault on the sha prior to the signals work (002f660) using the |
It's possible I need to do more cleanup on the rust side. I'm not super confident in rust. |
@MathieuDuponchelle - I think it might be a regression. I performed a bisect between 5643c02 and 002f660, I had to skip some commits, this was the result of my bisect:
|
@aiden-jeffrey yeah I was wondering if this was a regression from #83 , it looks likely that it is related. Why did you need to skip these commits? cc @amyspark |
Thanks for the reproducer by the way |
I got some unrelated errors trying to run the For half of these (for example 189f7bc) I got:
|
I see, annoying that the history doesn't build cleanly |
I tried reverting this merge commit and the issue still persists. |
See https://github.com/aiden-jeffrey/gstcefsrc/tree/aiden/try-revert. |
Hm, there was no merge commit, but 14 commits merged fast forward, I'm currently building the branch right before the first one of those |
Just spotted my mistake! Doh. |
yeah, some commit in #83 introduced the issue, @amyspark do you mind taking a look? |
Pushed a small change (removing log-severity) to that test repo. Now my bisect completes and identifies |
I imagine it relates to |
In some fashion for sure :) |
I think the issue here is |
Calling CefInitialize multiple times during a process lifetime is not supported: * https://magpcss.org/ceforum/viewtopic.php?f=6&t=16430 * https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=466 * https://stackoverflow.com/questions/73172139/cef-can-only-be-initialized-once-per-process-this-is-a-limitation-of-the-underl Prior to #83 we used to have a ShutdownEnforcer class, but as it was causing issues on OSX we will simply no longer shut down CEF at all. We can revisit if needed, but this is preferable to crashing. See #88 (comment) and below
Ok. Multiple pipelines just aren't really supported the way this element is currently written. If you run two cefsrc elements at the same time (without calling CefShutdown), Initialize never gets acalled, which means that the second cefsrc just has the properties of the first. |
@aiden-jeffrey CefInitialize being called a single time is not a problem, but yes the javascript flags property is only used for the first source, which isn't great, other properties don't affect |
Ah, |
Calling CefInitialize multiple times during a process lifetime is not supported: * https://magpcss.org/ceforum/viewtopic.php?f=6&t=16430 * https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=466 * https://stackoverflow.com/questions/73172139/cef-can-only-be-initialized-once-per-process-this-is-a-limitation-of-the-underl Prior to #83 we used to have a ShutdownEnforcer class, but as it was causing issues on OSX we will simply no longer shut down CEF at all. We can revisit if needed, but this is preferable to crashing. See #88 (comment) and below
Based on this sample, this adds a way to signal in javascript (from the webpage) a couple of things:
This is useful for pages that have non-trivial load times and may run out of content (webgl pages, pages with videos, etc).
There is a sample in the html/ directory that shows how to send the signals, e.g.:
To test, run a webserver in the html directory, say:
Then just specify the flag in a run pointing at that page: