So here is my code snippet:
using Toybox.Communications;
using Toybox.WatchUi;
using Toybox.Attention;
function phoneAppMessageHandler(message) {
var data = message.data;
Communications.emptyMailbox();
if (data != null) {
// Play connection tone
if (Attention has :playTone) {
Attention.playTone(ToneProfiles.appConnectionTone);
}
// Assign the server port
WheelData.webServerPort = data;
// And set connection state
WheelData.setIsAppConnected(true);
}
WatchUi.requestUpdate();
}
This snippet is called when a new message is received from the phone(basically a callback passed to Communications.registerForPhoneAppMessages())
And for some reason it can die on Communications.emptyMailbox() with System Error exception. I have no idea what is the cause. Btw, if you are interested in source, here it is: https://github.com/Wheellog/Companion.Garmin/blob/5ee2ec80077782a5efc11841ca22a9315a3d32a1
And the thing is, that it is pretty frequent! In ERA viewer I see that it is a really popular error, with 239(!!!) occurrences!
Here is a complete report:
Error Name: System Error
Occurrences: 239
First Occurrence: 2021-06-25
Last Occurrence: 2021-07-27
Devices:
fēnix® 6 / 6 Solar / 6 Dual Power: 16.70
fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 16.70
Forerunner® 945: 7.20
fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 16.70
fēnix® 6S / 6S Solar / 6S Dual Power: 16.70
Descent
Mk2 / Descent
Mk2i: 8.20
Forerunner® 945: 7.20
Descent
Mk2 / Descent
Mk2i: 4.20
vívoactive® 4: 5.80
Forerunner® 245: 7.20
vívoactive® 4S: 5.80
Enduro
: 16.70
App Versions: 2.3.8
Languages: ces, eng, fre, kor, pol, rus, spa, tha, ukr
Backtrace:
AppMessageHandler.phoneAppMessageHandler:7