Acknowledged
CIQQA-3244

Device Crashes When Deleting Item from Active CustomMenu

Deleting a menu item from a CustomMenu that is currently displayed causes the app to crash on the Epix 2 Pro 47mm.

The call to CustomMenu.deleteItem successfully removes the item, but on the next UI update, the app crashes with the following error:

Error: Array Out Of Bounds Error
Time: 2025-05-19T19:36:09Z
Part-Number: 006-B4313-00
Firmware-Version: 20.22
Language-Code: eng
ConnectIQ-Version: 5.1.1
Store-Id: 8a6b62f1-5450-4912-8799-2eeaf9779d97
Store-Version: 44
Filename: F56A2548
Appname: openHAB
Stack:

The issue also affects addItem, though less severely. When a new item is added, it does not appear during the next UI update.

In the simulator, both addItem and deleteItem work as expected—menu changes are reflected correctly on the next UI refresh.

Project: ohg on GitHub
Relevant CustomMenu implementation: BasePageMenu.mc

  • @Richard.ConnectIQ: I can still reproduce the issue with SDK 8.2.1.

    How can I assist you in further investigating it? Perhaps you could share the test app you used, and I can run it on my watch to help debug the behavior?

  • Hmmm, maybe it is device specific? With the CustomMenu being a native UI component, the code is probably not the same on every device? I was testing on an Epix 2 Pro 47mm, and unfortunately it is the only physical device I have.

  • I have tried it on a real device with a custom menu. I can delete items from it all the way until there are no items left to delete. Then I get an array out of bounds array which I believe is expected in this case. 

  • Hi Richard,

    Did you try it on a real device, and with a menu that is currently being displayed? This issue only occurs on real devices and specifically when deleting an item from a menu that is actively shown.

    I don’t think it’s related to my itemCount for two reasons:

    1. The ArrayOutOfBounds exception doesn't happen in my code, but in the API code during UI refresh. Since the API isn't aware of my custom itemCount, a bug in my code shouldn't cause that.

    2. When I apply the workaround mentioned in my comment below, everything works as expected. This workaround doesn’t affect my own itemCount logic.

    To me, this suggests that something in the onShow() method of CustomMenu / Menu2 is necessary to fully process item count changes.

  • I made a simple custom menu with multiple items and called deleteItem() on the 0th item and I wasn't seeing the out of bounds error until all the items had been deleted and it attempted to delete an item that didn't exist. 

    your call to deleteItem() call in BaseMenu.mc looks correct, but I can't tell exactly how you are handling views. Is it possible your itemCount used for indexing is getting out of sync with the number of items in your custom menu?