Unexpected token i in JSON at position 186

Hi,

I am getting this error on one of my plugins starting from build 3276. The most recent build that works correctly is 3274.

exception thrown: SyntaxError: Unexpected token i in JSON at position 186,SyntaxError: Unexpected token i in JSON at position 186 at JSON.parse (\<anonymous\>) at Array.\<anonymous\> (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:1:38113) at \_emscripten\_asm\_const\_iiii (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:1:46251) at Array.UP (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:7:121345) at xA (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:21:66814) at yA (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:21:79104) at wA (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:21:64799) at Array.GC (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:6:27541) at Object.D7a [as dynCall\_vii] (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:29:33675) at invoke\_vii (blob:https://coroniumcore.com/b98e1f5a-51df-4452-a2bb-6c9ccf39394a:1:303866)

You can view the test cases here. The error is triggered when clicking the “toggle” button. Everything else works fine.

3279 (not working) https://coroniumcore.com/html5/modal/3279/index-debug.html

3274 (working) https://coroniumcore.com/html5/modal/3274/index-debug.html

I’ve removed any kind of event listeners just to be sure. Any ideas?

-dev

Hi,

Actually 3274 doesn’t work fine because the was the build where apps were getting paused incorrectly (you have to click off the window first to get anything to work again), so it seems to have started from 3276.

-dev

It seem to be a problem when passing parameters from Lua to Javascript function. Could you provide your Lua code for that button handler?

Also, copy this file to Corona Simulator.app/Contents/Resources/

https://www.dropbox.com/s/0fhzr4q4q4i0nkn/webtemplate.zip?dl=1

It has extra debug output in failing place to console. This would make great combo with Lua code. Basically, something is going wrong when getting Lua parameters to JS function

Hi,

So I found out where the issue was. Apparently assigning a JS method to an onRelease handler will cause this error to happen.

This was the code I had:

local modal = require("modal") ... local toggleBtn = widget.newButton({ label = "Toggle", x = display.contentCenterX, y = display.contentCenterY + 80, onRelease = modal.toggle }) ...

Which would throw the error. I changed it to this and it works now:

local modal = require("modal") ... local function toggleModal() modal.toggle() end local toggleBtn = widget.newButton({ label = "Toggle", x = display.contentCenterX, y = display.contentCenterY + 80, onRelease = toggleModal }) ...

Not sure if that’s any cause for alarm, but it did fix the error.

-dev

Ye… Don’t do that. On release, has “event.target” property, which has a display object in it, which has like gazillion of properties etc, everything gets serialized. I’ll check it out - still shouldn’t crash.

Still, shouldn’t crash. Error was trying to use “nil” in Javascript… Will be fixed in the next daily build.

Hi,

Actually 3274 doesn’t work fine because the was the build where apps were getting paused incorrectly (you have to click off the window first to get anything to work again), so it seems to have started from 3276.

-dev

It seem to be a problem when passing parameters from Lua to Javascript function. Could you provide your Lua code for that button handler?

Also, copy this file to Corona Simulator.app/Contents/Resources/

https://www.dropbox.com/s/0fhzr4q4q4i0nkn/webtemplate.zip?dl=1

It has extra debug output in failing place to console. This would make great combo with Lua code. Basically, something is going wrong when getting Lua parameters to JS function

Hi,

So I found out where the issue was. Apparently assigning a JS method to an onRelease handler will cause this error to happen.

This was the code I had:

local modal = require("modal") ... local toggleBtn = widget.newButton({ label = "Toggle", x = display.contentCenterX, y = display.contentCenterY + 80, onRelease = modal.toggle }) ...

Which would throw the error. I changed it to this and it works now:

local modal = require("modal") ... local function toggleModal() modal.toggle() end local toggleBtn = widget.newButton({ label = "Toggle", x = display.contentCenterX, y = display.contentCenterY + 80, onRelease = toggleModal }) ...

Not sure if that’s any cause for alarm, but it did fix the error.

-dev

Ye… Don’t do that. On release, has “event.target” property, which has a display object in it, which has like gazillion of properties etc, everything gets serialized. I’ll check it out - still shouldn’t crash.

Still, shouldn’t crash. Error was trying to use “nil” in Javascript… Will be fixed in the next daily build.