Acknowledged
CIQQA-3761

bug: simulator crashes in ActivityRecording.createSession if name is both long and has non-ASCII character

In the simulator (SDK 8.3.0 and 8.4.0, any device I tried, i.e: fr55, fr955, fr965, venux1) crashes if the session name has non-ASCII characters and is "longer" (either in characters or in bytes) than some unknown length. Now I am not very surprised by this, because the documentation kind of hints it:

  • :name

    Required. This is the name that will be associated with the sport being recorded. The suggested maximum length of the name is 15 characters (some devices support longer names).

However it seems to be inconsistent, not related to 15 or 16, and I am not able to determine the max length either in chars or bytes for any device.

It looks like there's some code that only kicks in if there are non-ASCII characters (because the even 280 ASCII chars don't make it crash, but 9 LATIN2 chars crash it. 23 bytes don't crash it, but in other case 16 bytes crash...)

import Toybox.Activity;
import Toybox.ActivityRecording;
import Toybox.Lang;

function debugCreateSession(name as String, sport as Number, subSport as Number) as Session {
    log("name: " + name + "[" + name.length() + "], charArray: " + name.toCharArray().size() + ", utf8Array: " + name.toUtf8Array().size());
    return ActivityRecording.createSession({:name => name, :sport => sport as Activity.Sport, :subSport => subSport as Activity.SubSport});
}

function testOK() as Void {
    debugCreateSession("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 1, 1); // ASCII, 90 chars, 90 bytes, but it works even with 280 chars
    debugCreateSession("a2345678901234567890123456", 1, 1); // ASCII, 23 chars, 23 bytes
    debugCreateSession("á234567890123456789012", 1, 1); // 1st character non-ASCII, but only 22 chars, 23 bytes
    debugCreateSession("áéíóöőúü", 1, 1); // all characters non-ASCII, 8 chars, 16 bytes
    debugCreateSession("áéíóöőúüXYABCDE", 1, 1); // both ASCII and non-ASCII characters, 15 chars, 23 bytes
}

function testFAIL() as Void {
    debugCreateSession("á2345678901234567890123", 1, 1); // 1st character non-ASCII, and 23 chars, 24 bytes => CRASH
    debugCreateSession("áéíóöőúüű", 1, 1); // all characters non-ASCII, 9 chars, 18 bytes
    debugCreateSession("áéíóöőúüXYABCDEF", 1, 1); // both ASCII and non-ASCII characters, 16 chars, 24 bytes
}