Forum
    • Categories
    • Register
    • Login

    Full Expansions again....MASSIVE problems.....Warning swearing in the message....

    Scheduled Pinned Locked Moved General Questions
    22 Posts 4 Posters 70 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.
    • LindonL
      Lindon
      last edited by

      Full Expansions and the Expansion Handler are frankly a fucking nightmare...

      OK so I have a player.... and two expansions:

      These are listed in the right hand side in a viewport....this viewport is repeated INSIDE each expansion....

      So... start the player - and we get both expansions showing up correctly in the right hand side...

      Double click expansion 1 and it loads (correctly)
      Click its unload button and it unloads back to the player (correctly)
      Double click expansion 2 and it loads(Correctly)
      Click its unload button and it unloads back to the player (correctly)

      OK...

      Double click expansion 1 and it loads correctly...
      Whilst in expansion 1 double click expansion 2, and it loads correctly.....
      Now click the unload of expansion 2....and.....we should go back to the player, but we dont we get:

      UI mess....not the UI of the Player, but instead the UI of Expansion 1.....(I think)

      45571396-df5e-4217-b151-b4a8ca8fff7d-image.png

      How am I unloading the expansions I hear you ask... like this:

      eh.setCurrentExpansion("");

      So it seems the expansion handler is stacking up expansions as they load, and then unloading to the previously loaded expansion (but this is a guess..)

      ANYONE, anyone have any idea how to make this .....work... ???

      HISE Development for hire.
      www.channelrobot.com

      dannytaurusD HISEnbergH 5 Replies Last reply Reply Quote 0
      • dannytaurusD
        dannytaurus @Lindon
        last edited by

        @Lindon Not to trivialise your genuine issue - but that was a disappointing amount of swearing. I was hoping for more.

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

        HISEnbergH 1 Reply Last reply Reply Quote 0
        • dannytaurusD
          dannytaurus @Lindon
          last edited by

          @Lindon So you're manually unloading each expansion before loading the next one? Or are you relying on a HISE mechanism to unload/load?

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

          LindonL 1 Reply Last reply Reply Quote 0
          • HISEnbergH
            HISEnberg @dannytaurus
            last edited by

            @dannytaurus ๐Ÿคฃ ๐Ÿ˜‚

            Agreed the Expansion system deserves quite a bit more swearing. I think it could use a pretty serious overhaul especially on the UX side when developing.

            Sonic Architect && Software Mercenary

            dannytaurusD 1 Reply Last reply Reply Quote 1
            • dannytaurusD
              dannytaurus @Lindon
              last edited by dannytaurus

              @Lindon Is Engine.setCurrentExpansion useful here? What's the difference? ๐Ÿค”

              https://docs.hise.dev/scripting/scripting-api/engine/index.html#setcurrentexpansion

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

              LindonL 1 Reply Last reply Reply Quote 0
              • dannytaurusD
                dannytaurus @HISEnberg
                last edited by

                @HISEnberg Yes, indeed. I'm seeing so many issues here lately. One of my upcoming projects will use expansions so I'm invested in helping to sort it out ๐Ÿ˜œ

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

                1 Reply Last reply Reply Quote 0
                • HISEnbergH
                  HISEnberg @Lindon
                  last edited by

                  @Lindon Given that Rhapsody uses it (and I see some people posting issues with it actually, is this the same issue?), would david's system be an option for you here?

                  Sonic Architect && Software Mercenary

                  LindonL 1 Reply Last reply Reply Quote 0
                  • dannytaurusD
                    dannytaurus @Lindon
                    last edited by dannytaurus

                    @Lindon CLAUDE SAYS:

                    I traced it through the Full Instrument Expansion machinery and there's a genuine bug. Here's what's happening.

                    The mechanism

                    For "Full" expansions, restoring the base player after unload is handled by FullInstrumentExpansion::DefaultHandler (ScriptExpansion.cpp:2704). It stores a defaultPreset value tree and listens for expansion changes:

                    • expansion loaded (e != nullptr) โ†’ marks defaultIsLoaded = false
                    • expansion unloaded (e == nullptr) โ†’ reloads the stored defaultPreset

                    That stored default is (re)captured by setNewDefault(), which is called from the pointer overload only when transitioning from base:

                    // ExpansionHandler.cpp:363
                    void ExpansionHandler::setCurrentExpansion(Expansion* e, NotificationType notifyListeners)
                      {
                            if (currentExpansion != e)
                            {
                                    if (currentExpansion == nullptr)   // <-- "we are leaving the base state, snapshot it"
                                            FullInstrumentExpansion::setNewDefault(mc, mc->getMainSynthChain()-exportAsValueTree());
                                    ...
                    

                    The intent: snapshot the base player state the first time you leave it, so unload can return there.

                    The bug

                    The name-based overload sabotages that guard:

                    // ExpansionHandler.cpp:340
                    bool ExpansionHandler::setCurrentExpansion(const String& expansionName)
                      {
                            if (currentExpansion != nullptr && expansionName.isEmpty()) { ... return true; }
                    
                            currentExpansion = nullptr;   // <-- BUG: blindly nulls the pointer, no notification
                    
                            for (auto e : expansionList)
                                    if (e->getProperty(ExpansionIds::Name) == expansionName)
                                    {
                                            setCurrentExpansion(e);   // pointer overload now sees currentExpansion == nullptr
                                            return true;
                                    }
                            ...
                    

                    Trace the user's exact sequence (load exp1 โ†’ load exp2 directly โ†’ unload):

                    1. Load exp1: pointer overload sees currentExpansion == nullptr, snapshots the base as default. Correct. exp1 loads.
                    2. Load exp2 directly: name overload does currentExpansion = nullptr; without notifying, so the chain is still exp1's content. It then calls the
                      pointer overload, which now sees nullptr and calls setNewDefault(...) snapshotting the current chain = exp1. The saved "base default" is now silently overwritten with exp1's preset. exp2 loads.
                    3. Unload exp2 (setCurrentExpansion("")): DefaultHandler restores defaultPreset, which is now exp1's tree โ€” but exp1 is no longer the active expansion, so its sample/resource references resolve against the wrong (or no) expansion. Result: the corrupted "nothing loaded, nothing working" UI.

                    That's why load-then-load looks fine โ€” the corruption is silent and only bites at unload time. Lindon's instinct ("it unloads to the previously loaded expansion rather than the base") is essentially right.

                    Immediate workaround (no core change, script-only)

                    Always unload to base before switching expansions, instead of switching directly:

                    eh.setCurrentExpansion("");      // restores the real base default, defaultIsLoaded = true
                    eh.setCurrentExpansion("exp2");  // now snapshots base (correct) before loading exp2
                    

                    Because step 1 here restores the chain to the genuine base before the next load, setNewDefault captures the correct default and unload works. The bug only triggers on a direct expansionโ†’expansion switch.

                    The proper fix

                    Delete line 349 (currentExpansion = nullptr;) in the name overload and let the pointer overload manage the transition. With it gone, an exp1โ†’exp2 switch enters the pointer overload with currentExpansion == exp1, so the == nullptr guard correctly skips setNewDefault and the base default is preserved.

                    Bonus: reloading the same expansion by name becomes a proper no-op (the currentExpansion != e guard), instead of re-snapshotting.

                    The only behavior change: passing an unknown name would no longer implicitly unload the current expansion (it'd leave it loaded and return false), which is arguably more correct โ€” but worth noting since the empty-string unload path is handled separately above it anyway.

                    Does that align with what you're seeing?

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

                    LindonL 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @dannytaurus
                      last edited by

                      @dannytaurus said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                      @Lindon So you're manually unloading each expansion before loading the next one? Or are you relying on a HISE mechanism to unload/load?

                      I've tried both ways ...neither work. I suspect calling eh.setExapnsion("") from within the expansion itself(whihc is what i would need to do) is def. a no go... and myexperience is this is the case...it no fixy the problemy...

                      HISE Development for hire.
                      www.channelrobot.com

                      1 Reply Last reply Reply Quote 0
                      • LindonL
                        Lindon @dannytaurus
                        last edited by

                        @dannytaurus said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                        Load exp1: pointer overload sees currentExpansion == nullptr, snapshots the base as default. Correct. exp1 loads.
                        Load exp2 directly: name overload does currentExpansion = nullptr; without notifying, so the chain is still exp1's content. It then calls the
                        pointer overload, which now sees nullptr and calls setNewDefault(...) snapshotting the current chain = exp1. The saved "base default" is now silently overwritten with exp1's preset. exp2 loads.
                        Unload exp2 (setCurrentExpansion("")): DefaultHandler restores defaultPreset, which is now exp1's tree โ€” but exp1 is no longer the active expansion, so its sample/resource references resolve against the wrong (or no) expansion. Result: the corrupted "nothing loaded, nothing working" UI.

                        Almost exactly this yes.....

                        HISE Development for hire.
                        www.channelrobot.com

                        dannytaurusD 1 Reply Last reply Reply Quote 0
                        • dannytaurusD
                          dannytaurus @Lindon
                          last edited by

                          @Lindon Maybe you need the real bug fix in HISE then, rather than the manual unload/load steps in your scripts.

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

                          1 Reply Last reply Reply Quote 0
                          • LindonL
                            Lindon @HISEnberg
                            last edited by

                            @HISEnberg said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                            @Lindon Given that Rhapsody uses it (and I see some people posting issues with it actually, is this the same issue?), would david's system be an option for you here?

                            I think Rhapsody only lets you load an expansion and then return to the player to load the next one, so the stack doesnt get corrupted

                            HISE Development for hire.
                            www.channelrobot.com

                            dannytaurusD David HealeyD 2 Replies Last reply Reply Quote 0
                            • dannytaurusD
                              dannytaurus @Lindon
                              last edited by

                              @Lindon From David's recent discussion about an unload/back button, I think you're right.

                              However, my expansion-based project will need to work like yours - freely swapping expansions from a visible grid/list of available ones.

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

                              LindonL 1 Reply Last reply Reply Quote 0
                              • LindonL
                                Lindon @dannytaurus
                                last edited by

                                @dannytaurus said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                                @Lindon Is Engine.setCurrentExpansion useful here? What's the difference? ๐Ÿค”

                                https://docs.hise.dev/scripting/scripting-api/engine/index.html#setcurrentexpansion

                                I have no idea what the difference is between Engine and ExpansionHandler versions of this call...

                                HISE Development for hire.
                                www.channelrobot.com

                                dannytaurusD 1 Reply Last reply Reply Quote 0
                                • dannytaurusD
                                  dannytaurus @Lindon
                                  last edited by

                                  @Lindon I asked Claude, it says they both eventually call the same function but the Engine version is just a convenience where you don't have to created an ExpansionHandler first to load. You can just load with a String.

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

                                  1 Reply Last reply Reply Quote 0
                                  • LindonL
                                    Lindon @dannytaurus
                                    last edited by

                                    @dannytaurus said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                                    @Lindon From David's recent discussion about an unload/back button, I think you're right.

                                    However, my expansion-based project will need to work like yours - freely swapping expansions from a visible grid/list of available ones.

                                    So working on a work around ---- where I use a file to Request the load of an expansion:

                                    The player checks the request file every time it loads....if the request == NONE it just sets itself up as nomal... but if it == anything else - it loads the requested expansion...

                                    So the expansions themselves now no longer load other expansions, they just make a request and unload themselves...back to the Player who handles the load of the new expansion...

                                    its not great, in fact its a cludge, and Im about 20% of the way thru building it...

                                    HISE Development for hire.
                                    www.channelrobot.com

                                    dannytaurusD 1 Reply Last reply Reply Quote 0
                                    • dannytaurusD
                                      dannytaurus @Lindon
                                      last edited by

                                      @Lindon said:

                                      So the expansions themselves now no longer load other expansions,
                                      its not great, in fact its a cludge,

                                      I would say this is a good thing. Feels to me like the player should always handle expansion loading and unloading, not the expansions themselves.

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

                                      LindonL 1 Reply Last reply Reply Quote 0
                                      • LindonL
                                        Lindon @dannytaurus
                                        last edited by

                                        @dannytaurus well good or not..it works....

                                        HISE Development for hire.
                                        www.channelrobot.com

                                        1 Reply Last reply Reply Quote 0
                                        • David HealeyD
                                          David Healey @Lindon
                                          last edited by

                                          @Lindon said in Full Expansions again....MASSIVE problems.....Warning swearing in the message....:

                                          I think Rhapsody only lets you load an expansion and then return to the player to load the next one, so the stack doesnt get corrupted

                                          Correct. I believe this is how Christoph intended it to be used originally - I think he posted an example somewhere years ago that I was building off.

                                          Free HISE Bootcamp Full Course for beginners.
                                          YouTube Channel - Public HISE tutorials
                                          My Patreon - HISE tutorials

                                          LindonL 1 Reply Last reply Reply Quote 0
                                          • LindonL
                                            Lindon @David Healey
                                            last edited by

                                            @David-Healey yeah I'm sure that was the original intent, but if we all could be bothered to look back at my previous post about how I really didn't like expansions taking the full interface he pretty explicitly say it should be easy to build a "loader" widget and copy it into all the expansions, so I think I'm on safe ground here assuming that the loader should work as outlined above...

                                            HISE Development for hire.
                                            www.channelrobot.com

                                            David HealeyD 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            21

                                            Online

                                            2.4k

                                            Users

                                            13.8k

                                            Topics

                                            119.8k

                                            Posts