Simulator crash when passing null options parameter to makeWebRequest

o A Descriptive Title (i.e. “Simulator Freezes Launching App in Eclipse”)
Simulator crash when passing null options parameter to makeWebRequest

o The Environment:
Windows 10
Eclipse Neon.1 (4.6.1)
ConnectIQ 2.2.3

o A detailed description of the issue
The documentation explicitly says that passing null as the third parameter is allowed. If I do pass null, the simulator crashes with the following error.
Device id 1 name "A garmin device"
Shell Version 0.1.0
Failed invoking <symbol>
Unexpected Type Error
in makeWebRequest (D:\jenkins\workspace\Tech-CIQ-Win-Rel\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\Communications.mb:222)
in onSelect (C:\Users\Travis\workspace\X\source\XApp.mc:24)
in handleEvent (D:\jenkins\workspace\Tech-CIQ-Win-Rel\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:613)
Connection Finished
Closing shell and port


o Steps to reproduce the issue
Compile and run the test case below. Click the simulated device screen or the start button to trigger the web request.

o Any applicable additional information
N/A

o A code sample that can reproduce the issue (in email only if preferred)
using Toybox.Application as App;
using Toybox.Lang as Lang;
using Toybox.System as Sys;
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.Communications as Comm;

class XBehaviorDelegate extends Ui.BehaviorDelegate
{
function initialize() {
BehaviorDelegate.initialize();
}

function onSelect() {

var url = "query.yahooapis.com/.../yql";

var params = {
"q" => "select LastTradePriceOnly from yahoo.finance.quotes where symbol in (\"AMD\")",
//"q" => "select * from yahoo.finance.quotes where symbol in (\"AMD\")",
"format" => "json",
"env" => "store://datatables.org/alltableswithkeys"
};

Comm.makeWebRequest(url, params, null, method(:onQuote));

return true;
}

function onQuote(code, data) {
Sys.println(code);
Sys.println(data);
}
}

class XView extends Ui.View
{
function initialize() {
View.initialize();
}

function onUpdate(dc) {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();
}
}

class XApp extends App.AppBase
{
function initialize() {
AppBase.initialize();
}

function getInitialView() {
return [ new XView(), new XBehaviorDelegate() ];
}
}


Travis
  • Former Member
    Former Member
    Hey Travis,

    I'm not able to reproduce this with this code. I'm getting a crash if I press a key on the device in the sim (assuming that's because no behaviorDelegate is set up), but I am not getting the error that you are seeing. My console prints out:
    Device id 1 name "A garmin device"
    Shell Version 0.1.0
    Copying file.... 1% complete
    Copying file.... 3% complete
    Copying file.... 5% complete
    Copying file.... 7% complete
    Copying file.... 9% complete
    Copying file.... 11% complete
    Copying file.... 13% complete
    Copying file.... 15% complete
    Copying file.... 16% complete
    Copying file.... 18% complete
    Copying file.... 20% complete
    Copying file.... 22% complete
    Copying file.... 24% complete
    Copying file.... 26% complete
    Copying file.... 28% complete
    Copying file.... 30% complete
    Copying file.... 31% complete
    Copying file.... 33% complete
    Copying file.... 35% complete
    Copying file.... 37% complete
    Copying file.... 39% complete
    Copying file.... 41% complete
    Copying file.... 43% complete
    Copying file.... 45% complete
    Copying file.... 46% complete
    Copying file.... 48% complete
    Copying file.... 50% complete
    Copying file.... 52% complete
    Copying file.... 54% complete
    Copying file.... 56% complete
    Copying file.... 58% complete
    Copying file.... 60% complete
    Copying file.... 61% complete
    Copying file.... 63% complete
    Copying file.... 65% complete
    Copying file.... 67% complete
    Copying file.... 69% complete
    Copying file.... 71% complete
    Copying file.... 73% complete
    Copying file.... 75% complete
    Copying file.... 76% complete
    Copying file.... 78% complete
    Copying file.... 80% complete
    Copying file.... 82% complete
    Copying file.... 84% complete
    Copying file.... 86% complete
    Copying file.... 88% complete
    Copying file.... 90% complete
    Copying file.... 91% complete
    Copying file.... 93% complete
    Copying file.... 95% complete
    Copying file.... 97% complete
    Copying file.... 99% complete
    Copying file.... 100% complete
    File pushed successfully
    Connection Finished
    Closing shell and port
    Found Transport: tcp
    Connecting...
    Connecting to device...
    Device Version 0.1.0
    Device id 1 name "A garmin device"
    Shell Version 0.1.0


    -Coleman
  • Coleman,

    I ran into this several times yesterday working on an issue for another forum user. Let me revisit this and see if I can reproduce.

    Travis
  • I'm not able to reproduce this with this code. I'm getting a crash if I press a key on the device in the sim (assuming that's because no behaviorDelegate is set up)


    Yes, you must initiate the onSelect() behavior by pressing start key or tap the screen of the simulated device. Once you've done this, you will be looking at the same crash as I'm seeing.

    I've updated my instructions above to reflect that.

    Travis
  • Former Member
    Former Member
    Okay I was able to reproduce. We will be looking at this this week.

    Thanks,
    -Coleman
  • We've updated the documentation in this case to state that the options cannot be null. This change will be available in our next SDK release.