Random corona simulator error

Hello all, 

I’ve been getting this error shown in the picture below. It happens randomly (avg. 1 out of 10 times when relaunching), a simple ctrl+R relaunch will fix it. I don’t know if this is cause by my code or just the simulator error.

0TGfDNm.png

Any confirmation would be appreciated. Corona Simulator Version: 1137

P.S. my code has no randomize seed. Even when I comment out all the code and left an empty main function, this will occur ]:

Can you post the smallest code you have which reliably produces this problem? Which build are you using?

I think i have nail it down to where it is causing it. But still I have no idea where it is happening because all print functions work (even at the last line of scene:createScene).

I am using 1137, the latest stable build provided by corona sdk.

Issue to reproduce:

  • Under game.lua line 37 to 39, if i comment this out, there will be no crash that pops up.

  • Putting the issue into the fishclass.lua itself.

  • However if I didn’t comment line 37 to 39 under game.lua, you will still see “Scene fully created!” message at line 66 under game.lua even when the error pops up. Meaning that all creation ran successfully and it reaches the end of createScene

Here is the code:

main.lua

local sb = require "storyboard" local function main() sb.gotoScene( "assets.script.game" ) end main()

game.lua

-------------------- -- REQUIRE -------------------- -- STORYBOARD local sb = require "storyboard" local sceneGame = sb.newScene() sb.purgeOnSceneChange = true -- FISH CLASS local fish = require "assets.script.fishclass" -- SERIALIZER local sz = require "assets.script.jsonserializer" -------------------- -- GAME FUNCTIONS -------------------- -- GAME LOOP local function gameLoop() if ( sb.gameActive ) then -- NYI end end -- local function initGame() print( "Init game..." ) -- Create Display Group sb.backGroup = display.newGroup() sb.midGroup = display.newGroup() sb.frontGroup = display.newGroup() -- Create player fish sb.pet = nil local fishData = sz.loadData( "assets/data/testfish.json", sb.res ) sb.pet = fish.new( fishData ) -- Activate game after init completes sb.gameActive = true Runtime:addEventListener( "enterFrame", gameLoop ) print( "Init game completed!" ) end -------------------- -- STORYBOARD FUNC -------------------- function sceneGame:createScene( event ) print( "game.lua: Game Scene Created") -- Game space (Store in sb to allow access from classes) sb.gameSpace = self.view -- Initialize game initGame() -- Insert all display groups to game space sb.gameSpace:insert( sb.backGroup ) sb.gameSpace:insert( sb.midGroup ) sb.gameSpace:insert( sb.frontGroup ) print( "Scene fully created!" ) end function sceneGame:destroyScene( event ) Runtime:removeEventListener( "enterFrame", gameLoop ) -- NYI end sceneGame:addEventListener( "createScene" ) sceneGame:addEventListener( "destroyScene" ) return sceneGame 

fishclass.lua

-------------------- -- REQUIRE -------------------- -- STORYBOARD local sb = require "storyboard" -------------------- -- ENUM -------------------- local state = { idle = "idle", move = "move", eat = "eat", play = "play", sleep= "sleep" } -------------------- -- FISH CLASS -------------------- local fish = {} local fish\_mt = { \_\_index = fish } -- CONSTRUCTOR function fish.new( fishData ) print( "Creating fish..." ) -- Create the instance of the fish (sprite) local fishSheet = graphics.newImageSheet( fishData.sheetPath, fishData.sheetSetting ) local instance = display.newSprite( fishSheet, fishData.spriteSequence ) -- TEMPORARY instance:setSequence( state.idle ) instance:play() instance.x = display.contentWidth \* 0.5 instance.y = display.contentHeight \* 0.5 -- Add instance to middle group sb.midGroup:insert( instance ) print( "Fish created!" ) return setmetatable( instance, fish\_mt ) end -- MEMBER FUNCTIONS function fish:update() -- NYI end function fish:changeState( newState ) if ( self.state ~= newState ) then self.state = newState end end -- RETURN return fish

Have you tried it without the ‘.’ chars in your scene filenames?

Yeap, i think i nailed the problem… ImageSheet and Sprites…, they are not referenced elsewhere and got deleted. Figured this out when I tried to call sb.pet:setSequence( “idle” ) and sb.pet:play() in game.lua

Now i need to figure out how to make it work… Any help is welcomed :slight_smile:

What is sb.res?  I don’t see that defined anywhere?

its defined in the main. sb.res is basically a string = “resource”, I checked when loading files, if it is resource it will use the resource directory for path.

The problem is line 33, 34. If it is commented out, the crash will not happen. So i am thinking I did the class for creating sprites wrongly ]:

What are you seeing message wise in your console window?  When errors popup like that, there is another text window that has all your prints and more detailed warning messages.

If you are on a Mac and you’re starting Corona SDK by launching Corona SDK, please close it and re-launch it using the “corona-terminal” command in the CoronaSDK folder.

I’ve attached a simple reproduce file.

Run the main.lua with Corona simulator build 1137 (latest stable build for download)

  1. If it doesn’t crash right away:
  • Keep pressing command+R to relaunch till you see the crash.
  1. If it crashes right away:
  • Relaunch it until you don’t see a crash (It happens randomly)

Here is the picture from the console: VClqtg1.png

Can you post the smallest code you have which reliably produces this problem? Which build are you using?

I think i have nail it down to where it is causing it. But still I have no idea where it is happening because all print functions work (even at the last line of scene:createScene).

I am using 1137, the latest stable build provided by corona sdk.

Issue to reproduce:

  • Under game.lua line 37 to 39, if i comment this out, there will be no crash that pops up.

  • Putting the issue into the fishclass.lua itself.

  • However if I didn’t comment line 37 to 39 under game.lua, you will still see “Scene fully created!” message at line 66 under game.lua even when the error pops up. Meaning that all creation ran successfully and it reaches the end of createScene

Here is the code:

main.lua

local sb = require "storyboard" local function main() sb.gotoScene( "assets.script.game" ) end main()

game.lua

-------------------- -- REQUIRE -------------------- -- STORYBOARD local sb = require "storyboard" local sceneGame = sb.newScene() sb.purgeOnSceneChange = true -- FISH CLASS local fish = require "assets.script.fishclass" -- SERIALIZER local sz = require "assets.script.jsonserializer" -------------------- -- GAME FUNCTIONS -------------------- -- GAME LOOP local function gameLoop() if ( sb.gameActive ) then -- NYI end end -- local function initGame() print( "Init game..." ) -- Create Display Group sb.backGroup = display.newGroup() sb.midGroup = display.newGroup() sb.frontGroup = display.newGroup() -- Create player fish sb.pet = nil local fishData = sz.loadData( "assets/data/testfish.json", sb.res ) sb.pet = fish.new( fishData ) -- Activate game after init completes sb.gameActive = true Runtime:addEventListener( "enterFrame", gameLoop ) print( "Init game completed!" ) end -------------------- -- STORYBOARD FUNC -------------------- function sceneGame:createScene( event ) print( "game.lua: Game Scene Created") -- Game space (Store in sb to allow access from classes) sb.gameSpace = self.view -- Initialize game initGame() -- Insert all display groups to game space sb.gameSpace:insert( sb.backGroup ) sb.gameSpace:insert( sb.midGroup ) sb.gameSpace:insert( sb.frontGroup ) print( "Scene fully created!" ) end function sceneGame:destroyScene( event ) Runtime:removeEventListener( "enterFrame", gameLoop ) -- NYI end sceneGame:addEventListener( "createScene" ) sceneGame:addEventListener( "destroyScene" ) return sceneGame 

fishclass.lua

-------------------- -- REQUIRE -------------------- -- STORYBOARD local sb = require "storyboard" -------------------- -- ENUM -------------------- local state = { idle = "idle", move = "move", eat = "eat", play = "play", sleep= "sleep" } -------------------- -- FISH CLASS -------------------- local fish = {} local fish\_mt = { \_\_index = fish } -- CONSTRUCTOR function fish.new( fishData ) print( "Creating fish..." ) -- Create the instance of the fish (sprite) local fishSheet = graphics.newImageSheet( fishData.sheetPath, fishData.sheetSetting ) local instance = display.newSprite( fishSheet, fishData.spriteSequence ) -- TEMPORARY instance:setSequence( state.idle ) instance:play() instance.x = display.contentWidth \* 0.5 instance.y = display.contentHeight \* 0.5 -- Add instance to middle group sb.midGroup:insert( instance ) print( "Fish created!" ) return setmetatable( instance, fish\_mt ) end -- MEMBER FUNCTIONS function fish:update() -- NYI end function fish:changeState( newState ) if ( self.state ~= newState ) then self.state = newState end end -- RETURN return fish

Have you tried it without the ‘.’ chars in your scene filenames?

Yeap, i think i nailed the problem… ImageSheet and Sprites…, they are not referenced elsewhere and got deleted. Figured this out when I tried to call sb.pet:setSequence( “idle” ) and sb.pet:play() in game.lua

Now i need to figure out how to make it work… Any help is welcomed :slight_smile:

What is sb.res?  I don’t see that defined anywhere?

its defined in the main. sb.res is basically a string = “resource”, I checked when loading files, if it is resource it will use the resource directory for path.

The problem is line 33, 34. If it is commented out, the crash will not happen. So i am thinking I did the class for creating sprites wrongly ]:

What are you seeing message wise in your console window?  When errors popup like that, there is another text window that has all your prints and more detailed warning messages.

If you are on a Mac and you’re starting Corona SDK by launching Corona SDK, please close it and re-launch it using the “corona-terminal” command in the CoronaSDK folder.

I’ve attached a simple reproduce file.

Run the main.lua with Corona simulator build 1137 (latest stable build for download)

  1. If it doesn’t crash right away:
  • Keep pressing command+R to relaunch till you see the crash.
  1. If it crashes right away:
  • Relaunch it until you don’t see a crash (It happens randomly)

Here is the picture from the console: VClqtg1.png