-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
WebView UI: More customization? #462
Comments
The webview for DPF is still very primitive and work in progress. The webview wont talk to the plugin side directly but instead use state changes to notify host and plugin side that something happened. I think juce allowing "bind" functions is misguided, it comes from how they always have UI and DSP coupled together but on DPF side we always meant to separate them as much as possible. |
Great to see official webview UI support is coming to DPF, a couple of months ago I scaled down my project, made it ISC instead of GPL and renamed it to something that hints at DPF; the fancy name was unnecessary and regret it.
|
there is some fancy silly things being done on the Linux side, where we create a specially executable shared object if building as plugin. that way we do not need to ship with external tools, the only "tool" needed is ldlinux to make the magic work. but similar to your implementation there is IPC to talk between native UI class process and the new child process that does web things via gtk/qt.
not really, it was initially just an experiment made for https://github.com/moddevices/mod-desktop which needed a webview inside the plugin view. still dealing with some life things so no time for this right now, to be continued later in the year
Yeah we will have no such things on DPF side. my idea so far is simple: web views will have the same exact API as the DPF UI. That is how far it will go, intentionally. That way the implementation can be done in a quick way, and one that mimics existing APIs and (the eventual) documentation for those. Some basic goals:
PS: if someone wants to build a real (and opensource) plugin using webviews I would gladly collaborate on that. I would do the build system and project maintenance, but leave the web graphics to you. |
Cool, need to do some research it looks like my stuff can be simplified on Linux.
Thanks
🙏🏻
100%. Barebones interface and UI/DSP decoupling then the programmer can build any desired abstraction on top of it. Web should mimic the API as much as possible.
Could you elaborate on the reason for #1 ? all points are centered about minimalism which is desirable and I fully agree, but if there is an exception for DSSI there can be a second exception for the webview? I think webviews and network are highly intertwined and when used together lots of additional things can be done for almost free, which would be very hard/complex otherwise. Naturally, (nearly) everything optional can be built as a layer on top.
Nice! In my opinion webviews are not only useful for plugins with very complex UIs, but also open the door to programmers outside to the audio community for contributing which is cool. |
I just dont want to have to maintain network related code. the liblo dep was okay because:
Writing something like a websocket is out of scope for DPF due to its complexity, but bringing a whole dep just for it also seems overkill. |
I see; |
that is already possible in the develop branch if you include "extra/WebView.hpp" and set API is in https://github.com/DISTRHO/DPF/blob/develop/distrho/extra/WebViewImpl.hpp
Then call |
Thanks! Are there access to something like |
as already mentioned, no. and there might never be, still debating on that. |
Oh I found that file protocol is considered as safe, but there are some problems that is not solved: Premise: I'm porting a electron+vite app into VST, and I'd like to use DPF because of license (GPL is suck). Reasons:
|
you can zip the contents on the installer and still have the full size when installed. when dealing with browser-based plugins I think disk space is better used vs more ram having to load things in memory every time (browsers tend to be memory hogs, best to not make it worse) cant really about the file:// stuff, but I suspect web frameworks tend to have a way to deal with this. |
iirc vite has option to use Few more things:
|
ok fair, but it is not really something I have in mind to support for a first MVP. you can try to contribute to make this happen, which then doesn't depend on me doing it.
|
|
wouldnt that then imply that there is a webserver running? |
Yes, in fact found this myself the hard way. I was hoping for The same libwebsockets library provides sockets and file server, it is plain C, mature and actively maintained. I would expect "complaints" about this over and over... |
I looked a bit on how to do this on Qt side, since I need to get that updated first anyway. So I am more open to this idea, seems sensible enough. But I would leave it up to the plugin C++ code to decide what data to return, maybe only having a convenience class/code to return data based on a filesystem path but anything else would need to have custom code written by the developer. One thing I am not 100% sure of, because I only investigated the Qt side so far, this works by having a custom URL scheme handler on JUCE side too right? Or is it a custom domain that redirects to local resources? If we are ok with the custom URL scheme, I would try to get an API for it after finalizing my current Qt update. |
I looked into choc'c implemetation.
I think it's better to have dummy host ( |
choc is only used for windows, we can ignore the linux and mac side of it. need to investigate what is that about |
Oh I meant: I think it's okay to use custom url scheme, but there should be a dummy host for consistency (like choc does) |
well if all are able to work the same way there is no need for http hostname. |
@falkTX and @lucianoiam I just want to say that between y'all, the web UI support for DPF is shaping up to be excellent. I have previously implemented my own wrapper around webview and getting it working cross-platform is quite difficult (especially on Linux). Thank you so much. Let me know if I can pitch in. Among other things, I have a setup where CMake knows how to bundle a helper binary into the .so as a blob, which can be run directly from a memfd file descriptor. It would help dpfwebui, but I think DPF's method of launching the .so as a helper executable might be cleaner than my approach. But if this sounds useful I am happy to contribute. |
how does that setup work? my current linux approach was focused on not needing extra files to be shipped with the plugin in order to activate webview. so if I understood you right, you would:
or perhaps you really had an external binary needed for this, in that case the actual implementation does not really matter the tricky part on the linux side is that we need to run the webview in a separate process, because we are loading gtk or qt, likely conflicting with host symbols. so there needs to be an fork/exec in the whole thing (or posix_spawn if we want to be fancy). the "exec" part needs an actual executable program to run, which on my approach is the ld linux loader. would be nice to not have to rely on that, so we can be more resilient to changes and also work on BSDs. |
Hi @thirtythreeforty, just wanted to clarify that both implementations were developed independently and I would favor @falkTX 's for new projects. Back then when I started working on my project, there was no CHOC WebView (or at least I wasn't aware of its existence). But nowadays it just makes sense to use CHOC which is a better supported solution. Some things that can be still rescued from the (unofficial) dpfwebui:
Some things I don't like now:
Regarding multiple files in a plugin, highly likely the plugins are distributed with a bunch of HTML/JS/CSS files so an extra helper binary doesn't seem to hurt. But yes it would be cool to have everything self-contained. @falkTX maybe it would be possible to make the dpf:// protocol ( I think that was the name given to it on another dicussion ) read "files" appended to the plugin binary? like if it was a tarball. On the other hand, modern plugin formats already require a filesystem structure... |
if you look into the current qt code I added, there are already some steps for that. from my tests it is doable and not complicated to do at all. but a bit time consuming for supporting it on all frameworks and OSes. |
I was referring to how to pack the web files into the plugin, rather than how to access them which I agree it is better to skip the network. Anyways, fancy non-critical stuff. I haven't had a look at the code yet but everything sounds like going on the right track. |
Mostly correct, but in (2) the binary is "blobbed" into a char* array. The CMake helper code exports a C symbol and understands that the blob depends on the specified executable, so it's a single line to add another blob. (I use the same mechanism to blob the JavaScript bundle that runs in the webview.) And in (3) the blob is copied into, and executed directly from, a Linux memfd, so it never hits a filesystem at all. (There's some other prep in the forked child to set env vars such as GDK X11 setup, and closing file descriptors the DAW may have had open.) |
How does the DPF solution plan to handle embedding files in the plugin? |
there is no way to serve files yet, the default approach for now is using file:/// that points to the bundle/resources of the plugin embedding files is left to the developer to do, there is a tool to convert a file into C code https://github.com/DISTRHO/DPF/blob/main/utils/res2c.py but this can be done in many other ways. newer C++ standards even allow to but this is all very new stuff, there is not yet a single plugin that makes use of webgui from dpf. and yeah it works for that already, it does not use files but provides its own webserver |
The missing piece for an html file bundled into the plugin is the ability to either:
Since it's looking like the last bullet is how the consensus is leaning, what needs to be done to implement it? |
I'm porting my VST with choc's WebView into DPF.
I used
bind
,navigate
, andfetchResource
in that VST, but it seems like I can't use those APIs in DPF's WebView UI.It would be nice if those were accessible.
The text was updated successfully, but these errors were encountered: