showToast displays wrong string in simulator

I added a showToast to my app to help me debugging. I only use showToast in this one place in my app:

        if (WatchUi has :showToast) {
            WatchUi.showToast("onPhone", null);
        }

and a little but "later" in the code I log something:

        log("deleteTrack");

the string "deleteTrack" only appears in this one place in my code.

log is basically calling:

function log(msg as String) as Void {
    System.println(msg);
}

But for some reason this is what I see in the simulator on fr955:

Interesting. Looks like some compiler and/or simulator memory reference bug.

What's even more interesting is if I add a breakpoint somewhere after the call to showToast and before the use of the "deleteTrack" string then I see the correct string being displayed.

  • In the sim, is it only the 955?  What happens on a real device?  Is a 3rd party optimizer involved?

  • In the sim it happens to all the devices I tried (fr955, fr965, ee2). Both with SDK 7.4.3 and 8.0.0-Beta. No 3rd party optimizer.

    Regarding real device I don't know. Partially because the reason I added the toast is to help debugging something that works in the sim and doesn't (always) work on real device.

  • You want to try the real device, some things have never worked exactly the same in the sim as they do on all the real devices, especially those that use a native view.  The first was "Menu" way back when. as well as Menu2, MapView,  MapTrackView, and if I recall, ActionMenu

  • Yeah, clearly there is a bug here.

    I tried the same thing in the simulator with a complex data field (fr955):

    // WatchUi.showToast("foobar", null);
    WatchUi.showToast(Rez.Strings.AppName, null);

    It doesn't matter what I pass for the first argument, the text for the toast displayed by the simulator is usually a string literal from somewhere else in my code. Interestingly, if I switch away from the simulator (using CMD-TAB on Mac), then switch back, sometimes the correct string is displayed very briefly.

    This works fine on a real device (fr955), so I'd guess it's a bug in the sim, not the compiler.

    I think this merits a bug report.

    You want to try the real device, some things have never worked exactly the same in the sim as they do on all the real devices, especially those that use a native view.  The first was "Menu" way back when. as well as Menu2, MapView,  MapTrackView, and if I recall, ActionMenu

    There's a difference between the simulator being cosmetically different than the real device, and the simulator doing something completely wrong (displaying the wrong value).