Acknowledged

Logging SPORT_VOLLEYBALL crashes the watch

I am the developer of the Volleyball App (Volleyball | Garmin Connect IQ). When I try to record an Activity as SPORT_VOLLEYBALL, it fails and crashes the App on the watch. The documentation does not contain SPORT_VOLLEBALL, but it seems to exist anyway (documentation on the SPORT Types is outdated).

Is there a way for me to record a volleyball activity (if the watch supports it)? Right now I do the following, which always seems to log as SPORT_GENERIC, but at least it does not crash the watch:

using Toybox.ActivityRecording as Record;
if (Record has :SPORT_VOLLEYBALL) {
  session = Record.createSession({:name=>"Volleyball", 
                                  :sport=>Record.SPORT_VOLLEYBALL,
                                  :subSport=>Record.SUB_SPORT_EXERCISE});
} else {
    session = Record.createSession({:name=>"Volleyball", 
                                    :sport=>Record.SPORT_GENERIC, 
                                    :subSport=>Record.SUB_SPORT_EXERCISE});
}



  • Glad you got it worked out. Based on that, I'll close the bug report on our side.

  • Hi Travis, thank you for you feedback - you solved my issue! I have seen the documentation that ActivityRecording SPORT_* Constants were depreciated, but I haven't found the replacing constants in the documentation.

    And yes, I was not precise with my description - it crashes my App (in a way that can not be cought with try/catch), but the watch is still OK. I will update the app to use the correct constants.

  • You say it "crashes the watch" in the topic description and in the post itself, and you also say it "crashes the App on the watch". There is a world of difference between these cases, and it is important that we understand the behavior you are seeing. Can you clarify which is actually happening? Based on what I believe the issue to be, I fully expect your app to crash.

    I would not, under any circumstances, expect a ConnectIQ app to be able to crash the device. If you are indeed seeing a device crash/hang, please provide information about the specific device model and firmware version to help us reproduce the issue.

  • Your app is crashing because there is no constant ActivityRecording.SPORT_VOLLEYBALL. If you check the debug output in the vscode console or the contents of CIQ_LOG.yml, you'll likely see the symbol not found error on the line referencing that symbol. This is expected.

    The list of SPORT_* constants in the ActivityRecording module is incomplete and they are deprecated. If you want to specify SPORT_VOLLEYBALL, you need to reference the symbol from the Activity module. 

    If you need to support devices that don't have the constants in the Activity module (i.e., devices prior to 3.2.0), you can fall back to those in the ActivityRecording module. The following should work with all devices that have ActivityRecording support (necessary for the createSession call).

    import Toybox.Activity;
    import Toybox.ActivityRecording;
    
    
    // ...
    
      var sport;
      var subSport;
    
      if (Activity has :SPORT_VOLLEYBALL) {
          // 4.1.6 and later
          sport = Activity.SPORT_VOLLEYBALL;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else if (Activity has :SPORT_GENERIC) {
          // 3.2.0 and later
          sport = Activity.SPORT_GENERIC;
          subSport = Activity.SUB_SPORT_EXERCISE;
      } else {
          // 1.0.0 and later
          sport = ActivityRecording.SPORT_GENERIC;
          subSport = ActivityRecording.SUB_SPORT_EXERCISE;
      }
    
      session = ActivityRecording.createSession({
          :name => "Volleyball", 
          :sport => sport,
          :subSport => subSport
      });

  • Understood. I will look into this issue.