tlipinski/bitwig-novation-impulse

Sometimes crashes when selecting nested Post FX devices

Closed this issue · 3 comments

I have bravely convinced the controller to crash several times in a simple project with two FM8s and a Bitwig DrumMachine.

Each crash happened immediately after I switched focus from an instrument device (FM8) to a utility nested in the FM8's Post FX chain. One FM8 has a nested MeldaProduction MUtility. The other has a Bitwig Tool utility. I don't remember which of those nested devices I selected each time, so I don't know whether the crashes were related to a specific device.

At the moment, that's all I know about the variables involved. If I learn more, I'll let you know.

Does the Bitwig Controller API create a log when an extension crashes (or while it runs)? If I can find a log, I'll attach it.

@dhemery Luckily Bitwig has Control Script Console which you can acces with Ctrl+Enter shortcut and selecting it on the list. If script crashed there should be strack trace in red. Please attach it to the issue because I'm unable to reproduce it.
Thanks for reporting it!:)

Here's a stack trace. I do not know exactly what I was doing at the time.

java.lang.ArrayIndexOutOfBoundsException: 1
    at com.bitwig.extension.controller.api.ObjectArrayValue.get(SourceFile:21)
    at net.tlipinski.commands.RotaryBankUpCommand.lambda$new$0(RotaryBankUpCommand.java:18)
    at com.bitwig.flt.control_surface.values.IntegerValueProxy.notifyObservers(SourceFile:170)
    at com.bitwig.flt.control_surface.values.IntegerValueProxy.lambda$queueNotifyObservers$1(SourceFile:145)
    at GEd.mDc(SourceFile:92)
    at GEd.OpE(SourceFile:88)
    at lWn.qhd(SourceFile:126)
    at qda.nYf(SourceFile:74)
    at MU2.aCJ(SourceFile:246)
    at spe.mDc(SourceFile:233)
    at YpV.mDc(SourceFile:257)
    at aVX.run(SourceFile:75)
    at YpV.run(SourceFile:111)

Given the RotaryBankUpCommandClass in the stack trace, I tried hitting Impulse's Shift+PageUp and Shift+PageDown. I could not reproduce the crash that way. Those buttons scroll through the remote control pages as expected.

But I did discover that if I DON'T hold the Shift key, the MIDI key to the left of the rotary bank crashes the controller script every time:

java.lang.ArrayIndexOutOfBoundsException: 1
    at com.bitwig.extension.controller.api.ObjectArrayValue.get(SourceFile:21)
    at net.tlipinski.commands.RotaryBankUpCommand.lambda$new$0(RotaryBankUpCommand.java:18)
    at com.bitwig.flt.control_surface.values.IntegerValueProxy.notifyObservers(SourceFile:170)
    at com.bitwig.flt.control_surface.values.IntegerValueProxy.lambda$queueNotifyObservers$1(SourceFile:145)
    at GEd.mDc(SourceFile:92)
    at GEd.OpE(SourceFile:88)
    at lWn.qhd(SourceFile:126)
    at qda.nYf(SourceFile:74)
    at MU2.aCJ(SourceFile:246)
    at spe.mDc(SourceFile:233)
    at YpV.mDc(SourceFile:257)
    at aVX.run(SourceFile:75)
    at YpV.run(SourceFile:111)

In each case, it looks as if the RotaryBankUpCommand's callback is trying to access the name of a page that does not currently exist. (And your comment on line 17 gives me the impression you've had trouble with this before 😉)

I have a hunch that the the time Bitwig calls the lambda, the cursor remote controls page fetched on line 13 is out of date. (But I have not explored the API yet, so perhaps I stop speculating.)

Ok now I was able to reproduce it on device which has no pages at all by pressing Plugin button. But in such case the exception was java.lang.ArrayIndexOutOfBoundsException: 0 (notice different index). 0 is the default value if no other is set according to remoteControls.selectedPageIndex().addValueObserver(...) documentation. However in your case it's 1 which makes me think that it's like some stale value, maybe after moving between a few different devices?
I've added some checks so at least it shouldn't crash script now and maybe will allow some further investigation. By the way I moved this code out of Command to Callback -> https://github.com/tlipinski/bitwig-novation-impulse/blob/master/src/main/java/net/tlipinski/observers/callbacks/DisplayRotaryBankNameCallback.java.
Please check out the latest master revision:)

I have a hunch that the the time Bitwig calls the lambda, the cursor remote controls page fetched on line 13 is out of date. (But I have not explored the API yet, so perhaps I stop speculating.)

That's surely not the case:) Bitwig's API works in a different way. All objects like Track, CursorDevice or CursorRemoteControlsPage are kind of proxies to devices on Bitwig's GUI. You create all of them during initialization phase, you even aren't allowed to do it later. Then you always use the same instance which is supposed to point to correct device on GUI even if you switch between them.