Application.Storage for BitmapResource values on Vivoactive 3 (CIQ 3.0.3)

I'm trying to build a simple app that loads a BitmapResource via Communications.makeImageRequest() and then store it with Storage.setValue().
This works fine in the simulator but on a real device (Vivoactive 3) with CIQ 3.0.3, I get the below error. I don't have any other CIQ 3 compatible device to test on but according to all the docs I've read, the BitmapResource should be allowed as a value in CIQ 3.0.1 and above.

class QRCodeView extends WatchUi.View {
...

function onUpdate(dc) {
var image = Storage.getValue("BMP_123");
if( image == null ) {
fetchImage("123");
...

function fetchImage(code) {
var url = "chart.googleapis.com/chart + code + "&chs=100x100&cht=qr&chld=H%7C0";
Communications.makeImageRequest(url, null, null, method(:responseCallback));
...

function responseCallback(responseCode, data) {
if (responseCode == 200) {
Storage.setValue("BMP_123", data); // This call will fail
WatchUi.requestUpdate();
}
}
...



In CIQ_LOG.YML, I only see:
---
Error: File Not Found Error
Details: 'Failed invoking <symbol>'
Time: 2018-10-06T20:21:16Z
Part-Number: 006-B2700-00
Firmware-Version: '5.40'
Language-Code: swe
ConnectIQ-Version: 3.0.3
Filename: QRCODE
Appname: QRCode
Stack:
- pc: 0x10000407


I've tried setting all permissions in manifest.xml but get the same result. With trace logging (System.println()), I have verified that it's the Storage.setValue() call that causes the failure. If I skip the storage and head straight to drawing the fetched data with dc.drawBitmap(), everything works fine, so I would assume that it's a BitmapResource that I've been given.
  • Former Member
    Former Member
    Okay. I don't think this is broken at the VM level. There might be a discrepancy in the Sim or perhaps you ran the request and stored an image, then made the code changes. I tested on watch and sim with the following code:

    View.onUpdate(dc);

    if (image != null) {

    // Serialize and println()
    System.println("I am serializing the image...");
    Application.Storage.setValue("sImage", image);
    System.println("...I have serialized the image.");

    // Deserialize and println()
    System.println("I am deserializing the image and storing in a var...");
    var dImage = Application.Storage.getValue("sImage");
    System.println("...I have deserialized the image.");

    // Call the draw call with the deserialized image
    dc.drawBitmap((dc.getWidth()/2) - (image.getWidth()/2), 0, dImage);
    }
    }



    I'm going to keep digging, but I think it has something to do with the URL and the image it gets back. I think you are getting the response code that at request is valid, but the data may be null and you aren't handling the null case. Are you running this on the device via GCM on iOS or Android? I was running on Android, but I can try iOS. Perhaps there is a discrepancy in what they are doing with the data returned by your callback. I'll keep looking.

    Thanks,
    -Coleman
  • Okay. I don't think this is broken at the VM level. There might be a discrepancy in the Sim or perhaps you ran the request and stored an image, then made the code changes. I tested on watch and sim with the following code:

    View.onUpdate(dc);

    if (image != null) {

    // Serialize and println()
    System.println("I am serializing the image...");
    Application.Storage.setValue("sImage", image);
    System.println("...I have serialized the image.");

    // Deserialize and println()
    System.println("I am deserializing the image and storing in a var...");
    var dImage = Application.Storage.getValue("sImage");
    System.println("...I have deserialized the image.");

    // Call the draw call with the deserialized image
    dc.drawBitmap((dc.getWidth()/2) - (image.getWidth()/2), 0, dImage);
    }
    }



    I'm going to keep digging, but I think it has something to do with the URL and the image it gets back. I think you are getting the response code that at request is valid, but the data may be null and you aren't handling the null case. Are you running this on the device via GCM on iOS or Android? I was running on Android, but I can try iOS. Perhaps there is a discrepancy in what they are doing with the data returned by your callback. I'll keep looking.

    Thanks,
    -Coleman


    Thanks for the reply.
    I'm using Android as well. I'll try to write a "clean" app without any logic and play with the URL.
  • I have tried to simplify the app and using a non parameterized URL but I just can't get the Vivoactive 3 to store the BitmapResource.
    I've added a null-check and a println to show me that the image data is indeed a BitmapResource but it's still not letting me store it with Storage.setValue().
    Loading the BitmapResource from the web doesn't seem to be the issue.

    Coleman, have you managed to get Storage.setValue() to work on a Vivoactive 3 with CIQ 3.0.3?
    Do you know where I can find a full code sample that uses Storage.setValue() with a BitmapResource? I'm fully aware of that I'm a beginner with the SDK and that the most likely issue is with my code. I'm simply looking for the right way of doing this.

    Thanks again for looking into it.
    Regards
  • eribr I agree the issue is actually with the application.Storage of a bitmap. It seems to have nothing to do with makeImageRequest() or anything of the sort.

    If I just put the code below into onUpdate, and side load, the app will crash with the same error log. (i have rocket in my resources drawable file obviously)

    var rocket = WatchUi.loadResource(Rez.Drawables.rocket);
    Storage.setValue(1,rocket);
    var output = Storage.getValue(1);
    System.println(output.toString());
    dc.drawBitmap(100,100,output);


    This works in sim, but crashes on device.

    I will add this to the ticket and have engineering take a look.
  • I've found that the following devices are effected by this File Not Found issue at this time.
    fenix5
    VA3
    FR 935
    FR 735XT
  • ...but according to all the docs I've read, the BitmapResource should be allowed as a value in CIQ 3.0.1 and above.


    What docs say Application.Storage is 3.0.1 or later? From what I see in the API docs, Application.Storage of bitmap should be 2.4.0 or later.

    edit* I've confirmed it is 3.0.1 Later. I'm still curious where you found the info b/c to me the API Docs are unclear and may need to be updated.
  • It's in the change log for the 3.0.1 SDK You can see it in the readme file in the SDK's
    • Allow saving bitmap resources in Application Storage. Note that for audio content provider apps, downloaded images count against allowed media download size not overall app storage size. For all other app types the existing application storage capacities are enforced.

  • jim_m_58 Thanks Jim. I didn't think to look there!