HISE Logo Forum
    • Categories
    • Register
    • Login

    Webview! || Whats going on here??

    Scheduled Pinned Locked Moved General Questions
    19 Posts 6 Posters 304 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dannytaurusD
      dannytaurus @aaronventure
      last edited by

      @aaronventure Do you have any example code that shows this? And do you have any released plugins using this web view method for the UI?

      Meat Beats: https://meatbeats.com
      Klippr Video: https://klippr.video

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @dannytaurus
        last edited by

        @dannytaurus Don't have anything released yet but this is what you do in HISE

        const var Interface = Content.addWebView("Interface", 0, 0);
        Interface.set("width", 1600);
        Interface.set("height", 900);
        
        Interface.set("enableCache", true);
        Interface.set("enableCache", false); // comment this out before export
        
        Interface.set("enablePersistence", true);
        Interface.reset();
        
        Interface.set("saveInPreset", true);
        
        // Point to index.html
        var index = FileSystem.getFolder(FileSystem.AudioFiles).getParentDirectory().getChildFile("Images/Interface/build/index.html");
        Interface.setIndexFile(index);
        
        Interface.setConsumedKeyPresses("all");
        
        //=====================================================================
        
        Interface.bindCallback("DOMContentLoaded", function(args)
        {
        	// Push persisted state into the interface. Simply call this when the DOM loads in your index.html, 
        });
        
        //=====================================================================
        
        // WebView component callback
        // Only executes on init when persistent data is restored
        inline function onInterfaceControl(component, value)
        {
        	//Init stuff, recall config.ini, push persisted state back into the interface...
        };
        
        Content.getComponent("Interface").setControlCallback(onInterfaceControl);
        

        Your app.html while developing the interface is mostly empty anyway since you do everything in +layout.svelte and the individual components. But it does have

        	<script>
        		// Define a fallback for development mode
        		if (typeof window.DOMContentLoaded === 'undefined') {
        			window.DOMContentLoaded = function () {
        
        			};
        		}
        
        		document.addEventListener('DOMContentLoaded', function () {
        			// Call the function that will be defined in the HISE app
        			DOMContentLoaded();
        		});
        	</script>
        

        So you open the interface, it finishes loading and calls DOMContentLoaded, which is defined in HISE, and in HISE you simply take the value of the webview component (or wherever you're storing the state) and call a function in your interface https://docs.hise.dev/scripting/scripting-api/scriptwebview/index.html#callfunction.

        In your interface, you take the object that this function receives and reset your state.

        For every interaction, you're managing your Svelte state anyway. In your appState.svelte or whatever you call it, you simply define a callback which says when the state changes, it calls a function "storeToHISE" or whatever you call it, which again you define in HISE, which just receives the json and stores it in the webviewcomponent or in any other component via setValue() so that it can persist.

        1 Reply Last reply Reply Quote 1
        • ChazroxC
          Chazrox
          last edited by

          @oskarsh @aaronventure Thank You 🙏 Im gonna look more into this. Let me ask one thing before I move on, is this function dependent on being connected to the internet or a file in some app data folder?

          dannytaurusD A 2 Replies Last reply Reply Quote 0
          • dannytaurusD
            dannytaurus @Chazrox
            last edited by

            @Chazrox Unless @aaronventure says otherwise, as far as I know it's all local files. Webview is a bit of a misnomer really. It's just a local HTML file.

            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            ChazroxC 1 Reply Last reply Reply Quote 1
            • A
              aaronventure @Chazrox
              last edited by

              @Chazrox it's just a frameless browser instance that loads a html file. When you connect to a website with a normal browser app, it loads the same bundle, it's just served by a server. Here it's shipped in your dll. Put the bundle in the Images directory and point the Webview component towards it.

              The idea of Webview in general is to leverage the undoubtedly most mature frontend technology on the planet - the web platform technologies - to develop an interface for your desktop app.

              The Web tech is so far ahead of the native JUCE UI stuff in terms of what it can do, how well it runs and how easy it is to work with it. As a bonus, you also get skills that directly translate elsewhere outside HISE and even audio.

              Once you know this, the only missing thing will be how to point CloudFlare Pages or Github Pages to your github repo (it's like two clicks) and voila, you have a static website. Then if you learn Firebase or Supabase for example, you can ship a whole SSR web app with user accounts, database etc.

              ChazroxC 1 Reply Last reply Reply Quote 1
              • ChazroxC
                Chazrox @dannytaurus
                last edited by

                @dannytaurus def got my wheels turning...Thanks!

                1 Reply Last reply Reply Quote 0
                • ChazroxC
                  Chazrox @aaronventure
                  last edited by Chazrox

                  @aaronventure Mad potential is what Im hearing! Im definitely going to be learning this starting now. Thanks for the great breakdown! 🙏

                  Christoph HartC 1 Reply Last reply Reply Quote 0
                  • Christoph HartC
                    Christoph Hart @Chazrox
                    last edited by

                    The Web tech is so far ahead of the native JUCE UI stuff in terms of what it can do

                    I know my arguments are a bit tainted by the sunken cost fallacy of writing C++ GUIs for 10 years and offering a framework that builds on this tech stack, but this topic is currently creating a rift in the audio developer community and the jury hasn't decided yet. I've heard multiple complaints from developers getting into trouble with multiple instances or bugs that arise when people load in different plugins that all use a webview.

                    I guess the only way to find out is using it in real world projects and see if it holds up to the expectations.

                    you also get skills that directly translate elsewhere outside HISE and even audio.

                    That's maybe the biggest advantage of that approach though - not only you learn web UI development alongside the process, but the pool of people you can hire grows exponentially.

                    A 1 Reply Last reply Reply Quote 1
                    • A
                      aaronventure @Christoph Hart
                      last edited by

                      @Christoph-Hart said in Webview! || Whats going on here??:

                      I've heard multiple complaints from developers getting into trouble with multiple instances or bugs that arise when people load in different plugins that all use a webview.

                      Big if true, but also an issue that should then be fixed by DAW devs or JUCE devs or Webview2/Webkit devs. The potential is too insane to ignore. Though I've never seen two Webview based desktop apps interact with each other negatively, which means this could be a thing because they're within the same process/host, which might then put it into the DAW developers' court.

                      No doubt in some cases your users will have to be using the latest version of the DAW. That's the price. It's also a question of where HISE's Webview component is with tech, since HISE is still on JUCE 6.

                      Also, if your plugin has a skeumorphic interface with little or no animations or you're generally just using filmstrips, it's simpler and faster to just use HISE.

                      If it's not complex and you don't need performant animations, it's also faster and simpler to use HISE, and it's even possible to do a responsive design now with the changeable plugin resolution.

                      HISE is uniquely positioned here because of hot reloading. Actually developing a complex interface in JUCE is not super fun. Melatonin inspector helps, but man...

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @aaronventure
                        last edited by

                        @aaronventure Is there any overheard when the UI is minimized, or does it all go to sleep like the native UI?

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        Christoph HartC A 2 Replies Last reply Reply Quote 0
                        • Christoph HartC
                          Christoph Hart @d.healey
                          last edited by

                          Big if true, but also an issue that should then be fixed by DAW devs or JUCE devs or Webview2/Webkit devs.

                          That's true and you can expect that DAW or JUCE devs will go out of their way to fix the stuff, but if the issue is within the Webview2 layer you're basically dead in the water as you have to engage with the developer support of Apple and Microsoft and expect them to care about our little fringe use case (compared to where webview tech is used elsewhere).

                          1 Reply Last reply Reply Quote 1
                          • A
                            aaronventure @d.healey
                            last edited by aaronventure

                            @d-healey it gets destroyed completely, so even the memory gets cleared

                            1 Reply Last reply Reply Quote 2
                            • First post
                              Last post

                            24

                            Online

                            1.8k

                            Users

                            12.2k

                            Topics

                            106.0k

                            Posts