Catching exception from Comm.MailboxIterator.next() issue !!

Former Member
Former Member
I discovered new issue in Vivoactive HR FW. 3.30 . There is a problem for catching exception from Comm.MailboxIterator.next():

Log from CIQ_LOG.txt

WARNING: Error in mailbox callback
STORE_ID: 00000000000000000000000000000000

ERROR: Unexpected Type Error
DETAILS: Failed invoking <symbol>
STORE_ID: 00000000000000000000000000000000
CALLSTACK:
..Garmin notifier\source\Communication.mc (onIncomingMessage:153)
..Garmin notifier\source\Communication.mc (incomingMessage:41)

WARNING: Error in mailbox callback
STORE_ID: 00000000000000000000000000000000


Part of code from onIncomingMessage:

function onIncomingMessage(mailIter) {
if (mailIter instanceof Comm.MailboxIterator ) {
try {
/*line 153:*/ var message = mailIter.next(); //<- here is exception !!!
while(message != null) {
////some code
}
}
catch ( ex ) {
Log("Error during read message");
ex.printStackTrace();
}
}
Comm.emptyMailbox();
}


Calling Comm.emptyMailbox(); resolving my problem but in this case it didin't happen in onIncomingMessage() function. Unfortunatelly application alwais crashed when I tried to restart it. Only Call Comm.emptyMailbox() before Comm.setMailboxListener(method(:incomingMessage)); enables watchapp to restart and resolved the problem...

The question is: why block try.... catch doesn't work properly... Propably there is an issue in SDK, isn't it ?

BTW: Call following code when my application starts (i.e. in MyAPP constructor):

try {
Comm.emptyMailbox();
} catch (ex) {}


isn't good idea because application will crash on simulator. (On device won't.) But i think it is one way to allowing the application to restart in this case

Regards
  • Former Member
    Former Member over 8 years ago
    I believe I'm having the same issue. I'm writing a music control widget with song metadata, and it also suddenly started to throw this error, also when trying to get the first message from the mailbox iterator. The same code works perfectly fine in the simulator (with Android ADB BLE testing).

    Here's the log:
    ERROR: Unexpected Type Error
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    D:\Development\Garmin\TestApp\source\TestAppApp.mc (onMailReceived:63)

    WARNING: Error in mailbox callback
    STORE_ID: 00000000000000000000000000000000


    and this an excerpt with the problematic line:
    function onMailReceived(mailIterator) {

    if (mailIterator instanceof Comm.MailboxIterator )
    {
    try
    {
    var message = mailIterator.next(); // <--- // line #63 from the error log

    Sys.println("MSGRCV: " + message );

    // do something with the message
    }
    catch ( ex ) {
    Sys.println("Error during read message");
    ex.printStackTrace();
    }
    }

    Comm.emptyMailbox();
    Ui.requestUpdate();
    }


    I'm setting up the mailbox listener like this:
    function initialize() {
    AppBase.initialize();

    onMailReceivedCallback = method(:onMailReceived);
    Comm.setMailboxListener(onMailReceivedCallback);
    }


    I'm pretty sure OP is having the same problem, and I hope somebody has an idea as to what might be going on with this.
    Thanks
  • Hello All,

    I think you all may have found a bug. I have moved this thread to our Bug Reports thread. Please fill out the information needed according to the Bug Reports Forum Rules thread and I will create a ticket to investigate.

    Thanks,
    Coleman
  • Former Member
    Former Member over 8 years ago
    Unexpected Type Error when calling Comm.MailboxIterator.next() on device

    o The Environment:
    - Garmin Fenix 3 HR Sapphire: Software version 4.20
    - Eclipse Java Neon
    - Android Studio 2.2.3 for android companion app
    - Windows 10

    o A detailed description of the issue
    o Steps to reproduce the issue

    Provided in my previous post

    o Any applicable additional information
    - Messages sent from the companion app contain basic song metadata like title and artist name, of dictionary/map type.
    - Messages sent from the watch app to the phone are integers
    - The issue is temporarily resolved when removing the app from the device, then changing it's app id and then installing anew.
    The issue returns after a few received messages but I have not yet been able to determine a pattern as to why.
    - I am trying to send as few messages between the phone and watch as possible, but due to user interaction with the phone or watch app, sometimes 2 messages could be sent in quick succession.

    o A code sample that can reproduce the issue (in email only if preferred)
    Provided in my previous post
    If neccessary, I am willing to send my entire watch app and companion app source code via email.