Acknowledged

Watchface with a HTTP background process seems to not work properly anymore

A watch face uses a background process to send an HTTP request and retrieve the resulting data in the onBackgroundData function. It always worked fine, until a few days ago.

Indeed, it seems that since the arrival of the 4.2.x versions of the SDK, and the update of the firmware of the watches compatible with these new 4.2 versions, this process in the background no longer seems to work correctly.

For test purposes, I used the small program developed by jm_58, to see what happened, knowing that his program used to work very well with versions 4.1.x of the SDK.

Keeping the code as it is, with version 4.2.3, the program still works very well, the onBackgroundData function is well executed every 5 minutes. But, when I add the code that sends an HTTP request to a server, the problems begin:

- the raw data set is indeed recovered by the code (function onReceiveData(responseCode as Number, data as Dictionary<String, Object?> or String or Null) as Void, the array contains the expected data

- but, when calling Background.exit(data);, the onBackgroundData(data as Application.PersistableType) as Void function is never executed, even after waiting for several minutes, and several reiteration of the request

- the onUpdate function of the View file does not seem to be called either (a breakpoint placed on this line is never executed), we can no longer trace the code

- after a few moments, all the menus of the simulator become grayed out, no access to anything, except the File menu, we are then obliged to force the closing of the simulator, which no longer closes normally by File -> Exit

Finally, I end up with a table containing raw data, which I can no longer use and display on the screen after processing. The problem is that this malfunction also seems to occur on physical models (three users have informed me of this anomaly, the watch face no longer updates with the data, even after uninstalling-reinstalling the application).

I tried to go back, with a lower SDK version (4.1.7) but, unfortunately, it is no longer possible to compile for recent models with a version lower than 4.2.0. So I'm stuck, having found no viable solution to work around the problem (storing the raw dataset on disk then loading the array in the onUpdate) but, again, it doesn't work, going through the function onBackgroundData seems mandatory, but what do you do when this function no longer seems to be called by the system after executing and sending an HTTP request receiving a set of data?

I specify here that the data set never exceeds 8 Kb (we are more on 2-3 Kb), and that the problem exists on several models tested, with always the same symptoms (Epix 2, Fenix 7X, FR965, Venu 2 More in particular), suggesting that this is more a malfunction in the background task process rather than related to a particular model.

I think i have tried everything i could, without success, which is why i am reaching out here, hoping for some insights or suggestions, or a solution to help me out.

Thanks in advance.

Environment: Visual Studio on Mac

SDK version: 4.2.3

  • The problem seems solved, the process re-works again.

    There was no malfunction related to the code itself, I solved the problem by re-creating a new project then, copying and pasting the code as is in the new project and there, it worked again as Before. Another test, I deleted the "bin" directory from the project, it produced the same positive result.

    If it can help other developers who would encounter the same problem...

  • thanks jim.

    I just tried something. I copied and replace your simple request directly into my code:

    var options = {
    :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
    :headers => {
    "Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED
    }
    };

    Communications.makeWebRequest(
    {},
    options,
    method(:onReceiveData)
    );
    and just added a single line with System.println(data); into the function onBackgroundData(data), just to see what happened.
    I get the same result: onBackgroundData(data) is never called, the sim still freezes, time displayed by the WF is remaining at the time where the request was sent and, nothing else.
    So, this cannot be my HTTP request, it's not possible.
  • Try it and see if there's anything interesting in the ciq_log file.  That could explain why onBackgroundData is never called.

  • how would you do that if onBackgroundData is never called ?

  • It sounds like something is happening that's messing up the sim.  That's where trying a sideload may help to narrow things down (build a "debug" sideload)