Acknowledged
CIQQA-3719

Action Menu does not work with touch/mouse in the simulator - app crash

If you use an action menu using the device buttons everything seems to work fine. But if you use touch, i.e. click on the menu itself in the simulator with the mouse, the delegate is called, but the action menu is not popped and stays displayed.

This ultimately results in an app crash when you do use the buttons in an attempt to get off the menu:

selected 1

Error: Unexpected Type Error
Stack: 

Encountered app crash.

Thankfully, it all seems to work correctly on a real device, but means it cannot be tested at all on a touch device like the venu 2 or vivoactive 6.

This is broken in SDK 7.1.0 through to 8.4.0. It last worked in 6.2.4

Parents
  • Just to make everyone here happy, I added a custom delegate to my recreation code, and I get exactly the same result.

    No matter how I attempt to select an item or exit the menu, I see the same thing:

    - the action menu does not close itself (as the documentation claims it should)

    - the next BACK or ENTER keypress crashes the app. (Pressing UP or DOWN doesn't do anything).

    It doesn't matter whether I use the mouse to simulate a tap, use the mouse to click on a device button, or use the keyboard to simulate the first button press / action.

    However, to trigger the crash, the 2nd action has to be a button press (either via the mouse or keyboard) - simply clicking on the menu item (to simulate a tap) does not cause the crash for me.

    So it does seem that:

    - after the first BACK or ENTER the action menu is in some kind of broken state where it's still on the screen but it's not supposed to be. Again, the docs say: 

    "An action menu will dismiss it self on either user selecting a menu item or pressing back button."

    This isn't happening.

    - the second BACK or ENTER causes the action menu to try to select the item or close itself, but it can't do that because of the previous point

    TL;DR to cause the crash, do the following action twice: press BACK or ENTER.

    class VeryUsefulDelegate extends WatchUi.ActionMenuDelegate {
        function initialize() {
            ActionMenuDelegate.initialize();
        }
    
        function onBack() as Void {
            // this is displayed as expected after the first action, if the first action is BACK
            System.println("onBack"); 
        }
    
        function onSelect(item as WatchUi.ActionMenuItem) as Void {
            // this is displayed as expected after the first action, if the first action is ENTER (or a tap on the menu item)
            System.println("onSelect: " + item); 
        }
    }
    
    class TestView extends WatchUi.View {
    //...
        function onShow() as Void {
            var menu = new ActionMenu(null);
            menu.addItem(new ActionMenuItem({:label => "foo"}, null));
            WatchUi.showActionMenu(menu, new VeryUsefulDelegate());
        }
    //...
    }

    Sample output:

    onBack
    
    Error: Null Reference Error
    Details: Failed invoking <symbol>
    Stack: 
    
    Encountered app crash.

    Again, even if there's something wrong with my code, I don't think the sim should be crashing in this case.

    Environment: fr955, SDK 8.4.0, Windows

Comment
  • Just to make everyone here happy, I added a custom delegate to my recreation code, and I get exactly the same result.

    No matter how I attempt to select an item or exit the menu, I see the same thing:

    - the action menu does not close itself (as the documentation claims it should)

    - the next BACK or ENTER keypress crashes the app. (Pressing UP or DOWN doesn't do anything).

    It doesn't matter whether I use the mouse to simulate a tap, use the mouse to click on a device button, or use the keyboard to simulate the first button press / action.

    However, to trigger the crash, the 2nd action has to be a button press (either via the mouse or keyboard) - simply clicking on the menu item (to simulate a tap) does not cause the crash for me.

    So it does seem that:

    - after the first BACK or ENTER the action menu is in some kind of broken state where it's still on the screen but it's not supposed to be. Again, the docs say: 

    "An action menu will dismiss it self on either user selecting a menu item or pressing back button."

    This isn't happening.

    - the second BACK or ENTER causes the action menu to try to select the item or close itself, but it can't do that because of the previous point

    TL;DR to cause the crash, do the following action twice: press BACK or ENTER.

    class VeryUsefulDelegate extends WatchUi.ActionMenuDelegate {
        function initialize() {
            ActionMenuDelegate.initialize();
        }
    
        function onBack() as Void {
            // this is displayed as expected after the first action, if the first action is BACK
            System.println("onBack"); 
        }
    
        function onSelect(item as WatchUi.ActionMenuItem) as Void {
            // this is displayed as expected after the first action, if the first action is ENTER (or a tap on the menu item)
            System.println("onSelect: " + item); 
        }
    }
    
    class TestView extends WatchUi.View {
    //...
        function onShow() as Void {
            var menu = new ActionMenu(null);
            menu.addItem(new ActionMenuItem({:label => "foo"}, null));
            WatchUi.showActionMenu(menu, new VeryUsefulDelegate());
        }
    //...
    }

    Sample output:

    onBack
    
    Error: Null Reference Error
    Details: Failed invoking <symbol>
    Stack: 
    
    Encountered app crash.

    Again, even if there's something wrong with my code, I don't think the sim should be crashing in this case.

    Environment: fr955, SDK 8.4.0, Windows

Children
  • Now I have got up and had time to look at your code, I can get the same behaviour as you if I move my action menu to be pushed from onShow().

    If an action menu is pushed from onShow(), it does not get popped automatically irrespective of using touch or buttons, and crashes if the back or enter button is pressed after an initial selection which I can see does call the delegate.

    If an action menu is pushed from an input or behaviour delegate, it appears to work fine if you just use buttons, but if you attempt selection using touch, it does not get popped automatically, and crashes if the back or enter button is subsequently pressed

    Clearly there is a bug, and the exact symptoms seen vary slightly dependent on how it is invoked.

  • I completely agree with you. Even if you use something in an unusual way, or even incorrectly, it should not crash.

    I was simply trying to suggest why the behaviour you see differs slightly.

    It's clear, action menu is very broken in the sim. Thankfully, I'm not seeing any problems on real devices.