Acknowledged

App with API 6.4.2 doesn't start since firmware 16.22 anymore

Hi folks,
since the todays firmware on 16.22 on my fenix 7x my app (https://apps.garmin.com/de-DE/apps/fb178fa4-b5df-4b29-ac2f-cae16b991766) can't be started on the watch anymore. There is NO crash screen or anything. The app has no reaction at all. I've tryed a new installation of it - with the same failure.
In the SDK are njo changes. What's up here?
Greetings, Judex

  • The simulator doesn't has that bug. When you load the *.prg file of the bin-folder into the watch you may check the functionallity of your app. Or load a beta-version into the garmin app-store.

    When I write code, I always declare all global variables at one place. So the following changes where easyly and quickly to do for me.
    I put all global variables into the *.app file: after the "import"-declarations and before the class in the format:

    import Toybox.Something;
    
    public var foo1;
    public var foo2;
    public var ...
    
    class MyApp extends Application.AppBase {
    ...


    I've done that workaround with all global vars that declare objects and arrays. (by the way: the declaraton of primitives global vars still works well).
    Within the class inside of "function initialize()" I gave the variables the correct global format and initilal content:

      function initialize() {
        AppBase.initialize();
        foo1 = {
            :item1 => new Object(),
            :item2 => 123.45,
            :item3 => "Hello World"
        foo2 = new Bar();
        ...
      }

    With that changes my app works properly again - no problems anymore. There's no need of further checks for null or castings.

    Greetings, Judex

  • All these workarounds require to change the code in multiple places (because if you turn a variable to null able them you'll need to check for null or cast it to the non null type every place you use it, if you have type check on)

    Does this happen in the simulator as well, so at least devs can check it?

  • We tracked this down and have a fix. Unfortunately, that fix will not be able to roll out immediately.

    That said, we do have a workaround that can be used to avoid the issue. All that you need to do is to avoid initializing objects at global scope. As an example, if you have code like this...

    var gMyThing as MyThing = new MyThing();
    

    the workaround is to do something like this...

    var gMyThing as Thing or Null;
    
    class MyApp extends Application.AppBase {
    
      function initialize() {
        AppBase.initialize();
        gMyThing = new MyThing();
      }
    
      // ...
    }
    

    You could also add a factory function to produce the single shared object...

    var gMyThing as Thing or Null;
    
    function getThing() as Thing {
        if (gMyThing == null) {
            gMyThing = new Thing();
        }
        
        return gMyThing;
    }
    

    Or, you could put the object into a submodule of globals.

    module MyModule {
        var gMyThing = new MyThing();
    }
    
    

  • Hello Kyle. That's working fine. New Version is already released. Thank you a lot for your help. Best regards,

  • Thank you, Kyle. I'll try that at once.
    Greetings