App misbehaving on ForeRunner 935. Fine on simulator

Hi,

I have a watch app which works fine on a couple of watches, but on a 935 it misbehaves.  It's mean to draw lines on the screen, which are downloaded as a json file. This constitutes a map.

It works in the simulator, but on the watch the screen is blank and having got some debug logs off the watch itself, I get a strange output and hoped someone might be able to shed some light.

Each json file has an ID which is a string. This string is number/number/number (eg. 32754/25849/17) respresenting a map tile location

I print the current tiles which are being displayed. The code to populate the tile ids is:

var tiles = new [totalTilesX * totalTilesY];

var x = topLeftTileX;
var i = 0;
while(x <= bottomRightTileX){
var y = topLeftTileY;
while(y <= bottomRightTileY){
tiles[i]= x + "/" + y + "/" + z;
i++;
y++;
}
x++;
}

return tiles;

Then, later on, the code to print the ids

System.println(tiles);

On the 935 Simulator, and on my watch (vivoactive) and a fenix it prints the strings when I print the array.

[32739/25972/17, 32739/25973/17, 32739/25974/17, 32740/25972/17, 32740/25973/17, 32740/25974/17]

On the watch where it doesn't work, when I print the array of values, it prints

[f.a.q.b.l@92a741b2, f.a.q.b.l@92a7b611, f.a.q.b.l@92b1b63b, f.a.q.b.l@86f0b2d1, f.a.q.b.l@86f12730, f.a.q.b.l@86fb275a, f.a.q.b.l@7b3a23f0, f.a.q.b.l@7b3a984f, 
  • hmm... seems to have lost the end of my question. I'll pase it below:

    I can only guess this is the reference to the string class instance rather than the value of the string

    So 2 questions:


    1) why might this be? Is it expected on certain older versions, or have I miscompiled it for the wrong watch or perhaps the wrong CIQ version (3.1 appears to be the only option and I chose 935)
    2) Is this relevant or just a Red Herring?

    As per my previous post, I cannot get local log files on this watch, so what I can see is limited to what the watch can cope with writing to a remote POST endpoint for me to see. Additionally, I don't own the watch so each time I change something it's a couple of days before I can get the results.

    The logs appear to show that the json files it downloads are empty, or it may have mis-parsed them since it says they contain 0 points to draw, when they clearly do not.

    I will try to get more detailed logs, but the discrepancy between the simulator behaviour and the watch makes it very hard to investigate.

    Any help gratefully received.

    David

  • Answering my own question, it occurs to me that the fact I'm having to post this in a web request to see the output might mean it's converting it differently to how the println() statement would. I'm going to check that now...

    Frustratingly the version with remote logging doesn't start on my watch for whatever reason, but I'll go and try to fix that.

  • I have tried this on my watch and the simulator and the IDs print just fine. It's just the 935 that has this issue where it prints the class reference (?) (and won't render the images I want it to). No idea if the two are connected, but if there's some suggestion that others can give around why it exhibits this different behaviour, that would be appreciated.

  • Is there any more code you can share (like the network request code) or sample data? Where does z come from?

    I have a 935 so if you want to post a PRG I can do some light testing if you want.

    Do you have a link to the web service?

  • Thanks very much for the offer, that would be much appreciated.  I'll find somewhere to drop the app and post a link. Z is an integer that's passed in.

    In the meantime this is an example response (you can see z in the id at the end of the response)

    {
      "tiles": [
        {
          "features": [
            [
              "ppa",
              78.2,
              61.4,
              73.2,
              38.2,
              63.4,
              25.7,
              57.4,
              7.6,
              50.9,
              0,
              39.8,
              0,
              41.7,
              25.1,
              28.4,
              28.9,
              25.8,
              17.4,
              5.5,
              22.1,
              8.9,
              60.6,
              0,
              61.5,
              0,
              85.7,
              36.9,
              80.1,
              35.7,
              67.7,
              78.2,
              61.4
            ],
            [
              "lst",
              85.1,
              52.8,
              86.5,
              49
            ],
            [
              "lfo",
              84.9,
              54.6,
              85.1,
              52.8
            ],
            [
              "lfo",
              100,
              51.3,
              81.3,
              55.4
            ],
            [
              "lfo",
              27.4,
              7.6,
              25.9,
              8
            ],
            [
              "lfo",
              33.3,
              57.8,
              24.7,
              46.1,
              26,
              39.6,
              30,
              34.8,
              26.9,
              0
            ],
            [
              "lfo",
              86.5,
              49,
              86.6,
              38.4
            ],
            [
              "lfo",
              73.1,
              28.4,
              39.7,
              43.8,
              36,
              48.8,
              33.3,
              57.8
            ],
            [
              "lfo",
              2,
              0,
              3.4,
              12.7
            ],
            [
              "lre",
              53.1,
              82.2,
              55.1,
              100
            ],
            [
              "lre",
              16.6,
              100,
              16.4,
              98.5
            ],
            [
              "lre",
              0,
              11.2,
              25.9,
              8
            ],
            [
              "lre",
              63,
              0,
              61.2,
              3.2
            ],
            [
              "lre",
              95.1,
              0,
              98.1,
              19.5
            ],
            [
              "lre",
              100,
              5.7,
              84.7,
              8
            ],
            [
              "lse",
              58.7,
              0,
              61.2,
              3.2,
              73.1,
              28.4,
              78,
              41,
              86.3,
              79.7,
              88.2,
              100
            ]
          ],
          "info": {
            "tl": [
              51.50491765,
              -0.03852081299
            ],
            "br": [
              51.50355498,
              -0.03563690186
            ],
            "id": "32754/25849/17"
          }
        }
      ]
    }

    Code to request the content: 

    var options = {
        :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
        :headers => {
            "Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED,
            "x-api-key" => MapperApp.apiKey
        }
    }; 
    
    var location = MapperApp.MAP_URL + "/api/tiles/" + tileId;
    
    if(MapperApp.DEBUG) {
        System.println("loading tile:" + location);
    }
    
    Communications.makeWebRequest(
        location,
        {},
        options,
        callback
    );
    
    

    This calls the correct endpoint, but without debug logging, I can't easily see how it handles the response. 'callback' is a method reference to onReceiveTile

    function onReceiveTile(responseCode, data){
    
    if (responseCode==200 &&
      data instanceof Dictionary &&
      data.hasKey("tiles"))
    {
        mRequestFailureCount=0;
        mWebRequestsBackedOff =false;
        var tileData = data["tiles"][0];
        var id = loadTileData(tileData);
    
        if (MapperApp.DEBUG) {
            System.println("loaded " + id); 
        }
    } else {
        System.println("Error requesting map:" + responseCode);
    }
    
    

    function loadTileData(tileData) {
        var id = tileData["info"]["id"];
        var tile = new Tile(tileData);
        mCurrentTiles.put(id, tile);
        addToTileTypeCounts(tile);
        return id;
    }
    
    

    creating a new Tile() calls CountPoints in the initialize method:

    function countPoints() {
        mTotalPoints = 0;
        mTypeCounts = {};
    
        if(isEmpty()) {
            return;
        }
    
        var features = mData["features"];
    
        for (var i =0; i < features.size() ; i++) {
            mTotalPoints += (features[i].size() - 1) / 2;
            var type = features[i][0];
            var size = (features[i].size() - 1) / 2;
            if (mTypeCounts.hasKey(type)) {
                mTypeCounts.put(type, mTypeCounts.get(type) + size);
            } else{
                mTypeCounts.put(type, size);
            }
        }
    }
    

    this seems to return 0 points, but I need some better way to log to be sure.

    Obviously this is only a snippet, but hopefully it gives an idea of what's happening.

  • Well, text file debug logging works on my 935, so if you want to build a version with printlns, I wouldn't mind taking a few minutes to try it out.

  • Hi. I've dropped a copy of the PRG to dropbox https://www.dropbox.com/s/e1gibneqtakgur5/CFMap.prg?dl=0 temporarily.  It has quite a lot of trace logging in it and is compiled in debug mode in case that helps with any native log verbosity.

    When you start it up, and get a GPS signal you should get a map on the screen for your location (presuming you're in US/Europe), with roads etc drawn. I've turned off all the security on the webservice temporarily so you can test it out without having to jump through any hoops.

    If it doesn't work and if you can get some logs off it that would be much appreciated. If the app works just fine that's also good and tells us something.

    Really appreciate you spending a few minutes trying it.

  • No worries. I'll try to take a look at it sometime tonight (I'm on Eastern Time).

  • Hey, I tried out the app briefly. Got a GPS fix, and connected my watch to phone with bluetooth. Did not get a map.

    Couple of side issues:

    - When scrolling from the 2nd screen (pace) back to the 1st screen map, the display is briefly corrupt (it's a mix between the first and second screen).

    - When I press the BACK button on the pause screen, I expect to return to the regular activity screens, but I also expect the activity to remain paused (just like a native activity). Instead, the activity is resumed (as if I had selected Resume).

    This is an edited excerpt from the logs. (I replaced the tile #s with $X and $Y)

    loading settings id=data_view_map, [2, 7]
    total points in all tiles:0
    pointCounts:{}
    types To Render:[]
    total points in all tiles:0
    pointCounts:{}
    types To Render:[]
    route Id not set. Not loading route
    [$X/$Y/17, $X/${Y+1}/17, $X/${Y+2}/17, ${X+1}/$Y/17, ${X+1}/${Y+1}/17, ${X+1}/{Y+2}/17]
    No API Key. Not loading maps.
    No API Key. Not loading maps.
    No API Key. Not loading maps.
    No API Key. Not loading maps.
    No API Key. Not loading maps.
    No API Key. Not loading maps.
    Tile stats: loadedFromStorage=0, savedToStorage=0, loadedFromWeb=54

    Do I need an API key? Obviously I can't use app settings with a sideload, so you'll either have to hardcode what I need or post a .SET file (from the sim)