Under Review

bug: System.println and static inlined strings in the simulator cause the wrong string to be used

The following code ran on any device with at least CIQ 3.4.0 that supports toasts (i.e: fr955) in the simulator (either 7.4.3 or 8.0.0-Beta) will incorrectly display "other" instead of the expected "toast".

System.println("toast");
if (WatchUi has :showToast) {
    WatchUi.showToast("toast", null);
}
System.println("other");

I'm not 100% sure whether the bug is in println or maybe showToast or how the simulator implements some string functions or if it's a bug in the compiler, but the above few lines clearly reproduce it. I created a new Watch App with the Monkey C extension, and put the above code somewhere.

Note that the text logged is correct, only in the toast it's incorrect.

Parents
  • In my experience, it doesn't have anything to do with println().

    I've seen the problem happen with string literals that are passed to other functions, such as View.findDrawableById().

    My observations:

    - showToast() works properly on a real device (fr955) - the displayed text matches what's passed in as the first argument to showToast()

    - in the simulator, instead of displaying the specified text, the toast displays some random string literal from the app source code. It's always the same literal for any given build of the app, and it always seems to be a string literal that's passed into another function

    - it doesn't matter whether the 1st arg is specified as a string literal (e.g. "foo") or a string resource id (e.g. Rez.Strings.AppName). The same problem occurs either way

    - if I switch away from the sim (e.g. CMD-TAB in Mac) and switch back, sometimes the correct text is displayed very briefly (but then it switches back to the wrong tex)

    - I tested on SDK 7.4.3, Mac

    Related forum discussion: forums.garmin.com/.../

Comment
  • In my experience, it doesn't have anything to do with println().

    I've seen the problem happen with string literals that are passed to other functions, such as View.findDrawableById().

    My observations:

    - showToast() works properly on a real device (fr955) - the displayed text matches what's passed in as the first argument to showToast()

    - in the simulator, instead of displaying the specified text, the toast displays some random string literal from the app source code. It's always the same literal for any given build of the app, and it always seems to be a string literal that's passed into another function

    - it doesn't matter whether the 1st arg is specified as a string literal (e.g. "foo") or a string resource id (e.g. Rez.Strings.AppName). The same problem occurs either way

    - if I switch away from the sim (e.g. CMD-TAB in Mac) and switch back, sometimes the correct text is displayed very briefly (but then it switches back to the wrong tex)

    - I tested on SDK 7.4.3, Mac

    Related forum discussion: forums.garmin.com/.../

Children
No Data