Proper way to clear lists in View Model

I have a dialog rive file for my game. with an options list. whenever there is a new dialog line I need to clear the list of options and then add in the new options if they exist.

What’s weird is this was working for a while and stopped working in the latest update. This is using the WebGL2 advanced runtime.

Things I’ve tried:

My first way I did this was to save the option view models in the list to an array and then remove them when there was a new line using removeInstance(option). This was working for a while but then stopped after I updated rive.

Next I tried to get the length of the options and then do a for loop of the length and removeInstance(0); This wouldn’t work at all.

Then I tried doing a for loop like this:

const count = this.optionsList.size;
                    for(let i = 0; i < count; i++) {
                        this.optionsList.removeInstanceAt(i);
                    }

I thought this would result in an error since I assumed the list would get smaller and it would be an out of range exception but oddly this works the best. Occasionally, some options are still left though.

I’ve even tried reading the length of the optionsList in the watch window and it will show the size as 0 sometimes event when options are present in the list. I know it is advancing because it’s still animating. I’m using this function at the end of the update function:

this.stateMachine.advanceAndApply(elapsedTimeSec);

What’s the proper way to clear a list? Ideally I wish there was a clear function so I don’t have to remove all items individually.