Crash with Stage inserts

I have a crash that results from just a few lines of code.

[code]
local mySquare = display.newRect(100,100,100,100)
local stage = display.getCurrentStage()

print(stage) --<<
stage.insert(1, mySquare)

print(mySquare.parent) --<<
mySqaure.parent:insert(6, mySquare )
[/code]



  • This crash only seems to happen when changing the index at which the object is inserted.
    It does not happen when inserting at same index.


  • This crash also does not happen when using stage:insert for both insertion calls


  • Another interesting point if you call mySqaure.parent.insert(stage, 6, mySquare ) it does not crash





[import]uid: 106158 topic_id: 33024 reply_id: 333024[/import]

Hello,
On line 6, the correct notation is the colon, not dot… should be stage:insert(). However, you don’t need to manually insert anything on the stage… the stage is the master “parent” for all other display groups. The exception, I suppose, would be if you inserted an object into a child group and then later wanted to pull it out of that group and put it back on the core stage.

You’re getting the same result from both print() statements because, in Line 4, you’re printing the reference to the stage. Then, because the square is automatically placed on the stage in Line 1, its parent becomes the stage itself… thus mySquare.parent equals the stage.

You misspelled “square” in Line 10, which will result in an error of course.

Hope this helps!
Brent Sorrentino [import]uid: 9747 topic_id: 33024 reply_id: 131086[/import]

Hello,
On line 6, the correct notation is the colon, not dot… should be stage:insert(). However, you don’t need to manually insert anything on the stage… the stage is the master “parent” for all other display groups. The exception, I suppose, would be if you inserted an object into a child group and then later wanted to pull it out of that group and put it back on the core stage.

You’re getting the same result from both print() statements because, in Line 4, you’re printing the reference to the stage. Then, because the square is automatically placed on the stage in Line 1, its parent becomes the stage itself… thus mySquare.parent equals the stage.

You misspelled “square” in Line 10, which will result in an error of course.

Hope this helps!
Brent Sorrentino [import]uid: 9747 topic_id: 33024 reply_id: 131086[/import]

Please disregard my previous code (syntax errors etc). I was trying to type it in from memory at home. Now that I am at work I have it here in front of me.

local a = display.newGroup() local stage = display.getCurrentStage()  
  
local loo = display.newRect(100,100,100,255)  
  
stage:insert(1, loo)  
print("The Stage Ref is ", stage)  
timer.performWithDelay(3000, function() print(loo.parent) loo.parent:insert(6, loo) end)  

Basically what was happening was the object was disappearing then crashing.

Try this code for yourself and let me know.

I am using build 2012.894

UPDATE
On Windows Simulator
[import]uid: 106158 topic_id: 33024 reply_id: 131164[/import]

Is this your entire project test code? I tried it on my side, also Build 894 (but Mac Simulator) and it works just fine. No errors at all. It prints the stage reference ID, then 3 seconds later, prints the same value because it’s “loo’s” parent.

What is the exact error message you’re seeing in the Terminal? And again, is this your entire code, or just part of it?

Thanks,
Brent
[import]uid: 9747 topic_id: 33024 reply_id: 131179[/import]

Please disregard my previous code (syntax errors etc). I was trying to type it in from memory at home. Now that I am at work I have it here in front of me.

local a = display.newGroup() local stage = display.getCurrentStage()  
  
local loo = display.newRect(100,100,100,255)  
  
stage:insert(1, loo)  
print("The Stage Ref is ", stage)  
timer.performWithDelay(3000, function() print(loo.parent) loo.parent:insert(6, loo) end)  

Basically what was happening was the object was disappearing then crashing.

Try this code for yourself and let me know.

I am using build 2012.894

UPDATE
On Windows Simulator
[import]uid: 106158 topic_id: 33024 reply_id: 131164[/import]

Is this your entire project test code? I tried it on my side, also Build 894 (but Mac Simulator) and it works just fine. No errors at all. It prints the stage reference ID, then 3 seconds later, prints the same value because it’s “loo’s” parent.

What is the exact error message you’re seeing in the Terminal? And again, is this your entire code, or just part of it?

Thanks,
Brent
[import]uid: 9747 topic_id: 33024 reply_id: 131179[/import]

That is the all the code.

In the crash popup box i get:

**Problem signature:
Problem Event Name: BEX
Application Name: Corona Simulator.exe
Application Version: 12.0.894.0
Application Timestamp: 503c12d5
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Offset: a79000d3
Exception Code: c0000005
Exception Data: 00000008
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt**
I also will try it on the Mac simulator and get back to you.
[import]uid: 106158 topic_id: 33024 reply_id: 131249[/import]

Yes, this DOES crash under the MAC Simulator as well.

I am running on :

OS 10.7.5
2.13 Intell Core 2 Duo
4GB 800 MHz DDR2 SDRAM

**UPDATE******
Interestingly, the error displayed in the Corona Terminal says:

Corona Simulator(787, 0x7fff725a0960) malloc: *** error for object 0x10a8aba00: pointer being freed was not allocated.

So guess what was printed when I printed out the stage object? …It was 0x10a8aba00.
***************

I tested it on the iPad 1 it does not seem to crash but it does have the problem of the disappearing box. My guess is that if some additional code were added it would crash. (anyway I will leave that to the fine people at Corona to do)

HINT*
It may not be that obvious that your simulator has locked up until you try to use it to do something else like relaunch.
The more OBVIOUS Clue that something has gone wrong is that the white box disappears.

I am hoping that someone at Corona can look into this.

I know that this could be a pretty major problem for anyone using display groups on the stage and trying to mess with the draw order of display objects on the stage.

I am knee deep in the development of a Corona iPad App that uses the widgetCandy library for the UI. It took me many hours to trace down this bug and prove to myself that it was indeed Corona and not something from the library or my own code…In my code this bug causes display objects to disappear and eventually leads to a lockup / crash. That being said the crash was not immediately apparent and in the context of a sizeable project hard to find. I realize this example may not describe fully the bug issue but it should be enough for someone to take a look at.

:

[import]uid: 106158 topic_id: 33024 reply_id: 131261[/import]

The bug report (Case 18838) [import]uid: 106158 topic_id: 33024 reply_id: 131262[/import]

Hello again,
This is very odd! Just to confirm: you’ve copied *only* the 8 lines of code above into a NEW project… nothing else added, no 3rd-party add-ons like WidgetCandy, no “custom” config.lua, no “requires”, no scene manager like Storyboard or Director. Then you run it in the Mac Simulator using Build 894, and it crashes the Simulator?

When I do that, it works just fine. Mac Simulator, Corona Build 894, OSX 10.7.4 Lion. So theoretically, the only difference could be the version of OSX, if you have Mountain Lion or Snow Leopard or a different update of 10.7 Lion.

This is just too weird to explain, for sure.

Brent
[import]uid: 9747 topic_id: 33024 reply_id: 131285[/import]

Confirmed on what I am using,

  • only those 8 lines,

    • Just main.lua running in MAC simulator VERSION (2012.894(2012.8.27)) Mac 10.7.5

    • and on WIN Simulator VERSION (2012.894(2012.7.27)) Windows 7 Pro svc pack 1

    • you cant build for iOS without build.settings and config.lua so on the iPad i use them

I would say that the problem is more complicated than different version of OS,
since it does not work on Mac or Windows or iPad1.

Just to confirm with you,

After the second print statement executed, you still see a white box on the screen?
[import]uid: 106158 topic_id: 33024 reply_id: 131298[/import]

That is the all the code.

In the crash popup box i get:

**Problem signature:
Problem Event Name: BEX
Application Name: Corona Simulator.exe
Application Version: 12.0.894.0
Application Timestamp: 503c12d5
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Offset: a79000d3
Exception Code: c0000005
Exception Data: 00000008
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt**
I also will try it on the Mac simulator and get back to you.
[import]uid: 106158 topic_id: 33024 reply_id: 131249[/import]

Yes, this DOES crash under the MAC Simulator as well.

I am running on :

OS 10.7.5
2.13 Intell Core 2 Duo
4GB 800 MHz DDR2 SDRAM

**UPDATE******
Interestingly, the error displayed in the Corona Terminal says:

Corona Simulator(787, 0x7fff725a0960) malloc: *** error for object 0x10a8aba00: pointer being freed was not allocated.

So guess what was printed when I printed out the stage object? …It was 0x10a8aba00.
***************

I tested it on the iPad 1 it does not seem to crash but it does have the problem of the disappearing box. My guess is that if some additional code were added it would crash. (anyway I will leave that to the fine people at Corona to do)

HINT*
It may not be that obvious that your simulator has locked up until you try to use it to do something else like relaunch.
The more OBVIOUS Clue that something has gone wrong is that the white box disappears.

I am hoping that someone at Corona can look into this.

I know that this could be a pretty major problem for anyone using display groups on the stage and trying to mess with the draw order of display objects on the stage.

I am knee deep in the development of a Corona iPad App that uses the widgetCandy library for the UI. It took me many hours to trace down this bug and prove to myself that it was indeed Corona and not something from the library or my own code…In my code this bug causes display objects to disappear and eventually leads to a lockup / crash. That being said the crash was not immediately apparent and in the context of a sizeable project hard to find. I realize this example may not describe fully the bug issue but it should be enough for someone to take a look at.

:

[import]uid: 106158 topic_id: 33024 reply_id: 131261[/import]

Yep, I still see the white box, and no errors whatsoever.

I assume your config.lua and build.settings are totally “vanilla”? Nothing weird inside them?

Did you try a slightly more simple scenario without the timer and embedded function, like this?

local a = display.newGroup() -- without this line it seems to not crash  
local stage = display.getCurrentStage()  
   
local loo = display.newRect(100,100,100,255)  
   
stage:insert(1, loo)  
print("The Stage Ref is ", stage)  
loo.parent:insert(6, loo)  
print("Loo's parent is ", loo.parent)  

Finally (and this probably isn’t related, but I’m curious), why are you trying to insert an object at position 6 in the hierarchy, when there’s nothing in indexes 2-5? Personally, I never use the strict “index declaration” on inserting into display groups (although it is valid, according to the documentation). I simply add my my objects in the proper bottom-to-top order among layers, and if I need to ever force something to the front or back, I use object:toFront() or object:toBack(). Again, I don’t think this is the cause of your crash, I’m just asking if you have a reason or if this is merely for testing purposes.

Brent

[import]uid: 9747 topic_id: 33024 reply_id: 131302[/import]

The bug report (Case 18838) [import]uid: 106158 topic_id: 33024 reply_id: 131262[/import]

I am using a third party library called widget candy mainly for the widgets and windows it allows you to place on screen and edit easily. Since my App allows you to edit and design an interface it needs to be able move or stack widgets from front to back. The library automatically handles all of the ordering by storing a zindex for each Widget.

With a Corona display group the index is used to determine where in the draw stack an object is.

For Instance, adding object to position 1 of a display group means that object is now drawn over the others in the group. Inserting at 1 also moves all of the other members up by 1. This is the same as with the stage which is also a display group. Ultimately, you should be able to insert into any position you want within a display group as it an ordered collection.

If you had a collection of controls all over top of each other and you wanted to put your object in the center of the stack how would you determine where that was simply using toBack or toFront?

[import]uid: 106158 topic_id: 33024 reply_id: 131307[/import]

Yeah, I know how the z-indexing of display groups works. I was just curious what your needs for the specific index declaration was. When I “layer” items in a group, typically I just declare them in bottom-to-top order. But in your case, I see you need very specific control to (perhaps) shift the widgets’ z-index around post-declaration.

Is the error still occurring with the simplified code I suggested? [import]uid: 9747 topic_id: 33024 reply_id: 131313[/import]

I looked at your bug case and the problem is with this line of code:

timer.performWithDelay(3000, function() print(loo.parent) loo.parent:insert(6, loo) end)

In the sample you provided the stage only has two objects and you are now trying to re-insert the object at the 6th position. That is a bug in your code and not in Corona. Corona should have checked for that condition and not crashed. [import]uid: 7559 topic_id: 33024 reply_id: 131325[/import]

Hello again,
This is very odd! Just to confirm: you’ve copied *only* the 8 lines of code above into a NEW project… nothing else added, no 3rd-party add-ons like WidgetCandy, no “custom” config.lua, no “requires”, no scene manager like Storyboard or Director. Then you run it in the Mac Simulator using Build 894, and it crashes the Simulator?

When I do that, it works just fine. Mac Simulator, Corona Build 894, OSX 10.7.4 Lion. So theoretically, the only difference could be the version of OSX, if you have Mountain Lion or Snow Leopard or a different update of 10.7 Lion.

This is just too weird to explain, for sure.

Brent
[import]uid: 9747 topic_id: 33024 reply_id: 131285[/import]