Subpages become unreachable upon changing active Project

Hi, accidentally, while moving from one project to another in the same session, I’ve noticed that not all of my subPages are getting restored when moving back to the previous project AND at the same time I have changed one of my subPages to the currently active project.

Here are some screenshots to better describe the issue.

When we load an empty project and the script starts, we get this:

εικόνα

As we can see, the device is activated, and two subPages are activated as well, belonging to two subPages Areas. No problem so far.

Let’s now create a new project. The logger shows:

εικόνα

Again, nothing wrong here (even though we can notice doubling but it’s not to worry I guess).
We can see the previous project properly getting deactivated with the connected subPages, and then the other one getting activated and so are the subPages as they should.

Now, let’s go back to our previous project, only this time let’s move to the second subPage of the second subPages area and log:
εικόνα

Again, no problem at all. But now, let’s move to our other project for the final time:

εικόνα

As we can see, upon reactivating the other project, the second subPage is no longer getting activated! Furthermore, if one tries to workaround this (I did try) and trigger it manually with specific methods, again, it doesn’t get triggered. Seems like got recycled. But did it?
If we now reactivate the other project, we get:

εικόνα

To my surprise the subPage we previously have no contact with, now gets deactivated (as it should) upon the project’s deactivation! But then again, it’s not getting activated to our next project.

I’m trying to see this issue as something I overlooked while dealing with subPages, but it may be a bug. Here’s the code to reproduce the issue:

var midiremote_api=require('midiremote_api_v1')

var deviceDriver = midiremote_api.makeDeviceDriver('Issues', 'SubPagesActivation', 'Issue')

var midiInput = deviceDriver.mPorts.makeMidiInput()
var midiOutput = deviceDriver.mPorts.makeMidiOutput()

deviceDriver.makeDetectionUnit().detectPortPair(midiInput, midiOutput)
    .expectInputNameContains('loopMIDI 1')
    .expectOutputNameContains('loopMIDI 2')

var surface=deviceDriver.mSurface

var buttons=createButtons(4)

function createButtons(numOfButtons){

    var buttons=[]

    for(var i=0;i<numOfButtons;i++){

        var button=surface.makeButton(i,0,1,1)
        button.mSurfaceValue.mMidiBinding
            .setInputPort(midiInput)
            .bindToControlChange(0,24+i)

            buttons.push(button)

    }

    return buttons 

}

var page=deviceDriver.mMapping.makePage("aPage")

var subPagesAreas=[page.makeSubPageArea("subPageArea0"),page.makeSubPageArea("subPageArea1")]

var subPages=[subPagesAreas[0].makeSubPage("subPageArea00"),subPagesAreas[0].makeSubPage("subPageArea01"),subPagesAreas[1].makeSubPage("subPageArea10"),subPagesAreas[1].makeSubPage("subPageArea11")]

var transportValues=page.mHostAccess.mTransport.mValue

var bindings=[transportValues.mStart,transportValues.mStop,transportValues.mRewind,transportValues.mForward]

var i=0
bindings.forEach(function(binding){

    var realIndex=Math.floor(i/2)

    page.makeValueBinding(buttons[realIndex].mSurfaceValue,binding).setSubPage(subPages[i])
    
    subPages[i].mOnActivate=function(activeDevice,activeMapping){

        console.log("activating subPageArea "+Math.floor(this.i/2).toString()+" subPage "+(this.i % 2).toString())

    }.bind({i})

    subPages[i].mOnDeactivate=function(activeDevice,activeMapping){

        console.log("DEactivating subPageArea "+Math.floor(this.i/2).toString()+" subPage "+(this.i % 2).toString())

    }.bind({i})

    i++

})

page.makeActionBinding(buttons[2].mSurfaceValue,subPagesAreas[1].mAction.mPrev)

page.makeActionBinding(buttons[3].mSurfaceValue,subPagesAreas[1].mAction.mNext)


deviceDriver.mOnActivate=function(activeDevice){
    console.log("project/device activated")
}

deviceDriver.mOnDeactivate=function(activeDevice){
    console.log("project/device DEactivated")
}
1 Like