Anyone else having a problem with physics.setDrawMode?

If I try to use either:

physics.setDrawMode(“debug”)
physics.setDrawMode(“hybrid”)

it works for a couple seconds before the simulator crashes. Everything works fine in normal mode.

Here’s part of the details:

Process: Corona Simulator [9646]
Path: /Applications/Corona Game Edition Beta/Corona Simulator.app/Contents/MacOS/Corona Simulator
Identifier: com.anscamobile.Corona_Simulator
Version: ??? (1.0)
Code Type: X86 (Native)
Parent Process: bash [9644]

Date/Time: 2010-09-18 22:40:25.727 -0400
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6

Interval Since Last Report: 714216 sec
Crashes Since Last Report: 3
Per-App Interval Since Last Report: 8102 sec
Per-App Crashes Since Last Report: 3
Anonymous UUID: CB9C267F-2AE4-46D8-862F-70C7449C9AD4

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 …nscamobile.Corona_Simulator 0x000273f0 0x1000 + 156656
1 …nscamobile.Corona_Simulator 0x00027b2e 0x1000 + 158510
2 …nscamobile.Corona_Simulator 0x000529ab 0x1000 + 334251
3 …nscamobile.Corona_Simulator 0x000250d9 0x1000 + 147673
4 …nscamobile.Corona_Simulator 0x0002f58f 0x1000 + 189839
5 …nscamobile.Corona_Simulator 0x00026e66 0x1000 + 155238
6 com.apple.Foundation 0x91597968 __NSFireTimer + 141
7 com.apple.CoreFoundation 0x97c0270b __CFRunLoopRun + 8059
8 com.apple.CoreFoundation 0x97c00094 CFRunLoopRunSpecific + 452
9 com.apple.CoreFoundation 0x97bffec1 CFRunLoopRunInMode + 97
10 com.apple.HIToolbox 0x9209af9c RunCurrentEventLoopInMode + 392
11 com.apple.HIToolbox 0x9209ad51 ReceiveNextEventCommon + 354
12 com.apple.HIToolbox 0x9209abd6 BlockUntilNextEventMatchingListInMode + 81
13 com.apple.AppKit 0x94936a89 _DPSNextEvent + 847
14 com.apple.AppKit 0x949362ca -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
15 com.apple.AppKit 0x948f855b -[NSApplication run] + 821
16 com.apple.AppKit 0x948f05ed NSApplicationMain + 574
17 …nscamobile.Corona_Simulator 0x00002bc6 0x1000 + 7110

Thread 1: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x97929942 kevent + 10
1 libSystem.B.dylib 0x9792a05c _dispatch_mgr_invoke + 215
2 libSystem.B.dylib 0x97929519 _dispatch_queue_invoke + 163
3 libSystem.B.dylib 0x979292be _dispatch_worker_thread2 + 240
4 libSystem.B.dylib 0x97928d41 _pthread_wqthread + 390
5 libSystem.B.dylib 0x97928b86 start_wqthread + 30

Thread 2:
0 libSystem.B.dylib 0x97922086 select$DARWIN_EXTSN + 10
1 com.apple.CoreFoundation 0x97c4080d __CFSocketManager + 1085
2 libSystem.B.dylib 0x9793081d _pthread_start + 345
3 libSystem.B.dylib 0x979306a2 thread_start + 34

Thread 3:
0 libSystem.B.dylib 0x979289d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x97928f68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x97928b86 start_wqthread + 30

Thread 4:
0 libSystem.B.dylib 0x979289d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x97928f68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x97928b86 start_wqthread + 30

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0xbfffe5e8 ebx: 0xbfffe5e8 ecx: 0x00000011 edx: 0x00000000
edi: 0x0182c2a0 esi: 0x00000000 ebp: 0xbfffe548 esp: 0xbfffe530
ss: 0x00000023 efl: 0x00010286 eip: 0x000273f0 cs: 0x0000001b
ds: 0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x0000000f
cr2: 0x00000000 [import]uid: 8434 topic_id: 2108 reply_id: 302108[/import]

Does the “DebugDraw” sample crash for you, or is this a different project? [import]uid: 3007 topic_id: 2108 reply_id: 6385[/import]

The “DebugDraw” sample works fine. Seems to be my project that has the problem with it. [import]uid: 8434 topic_id: 2108 reply_id: 6388[/import]

Do you have physics included and started before you call setDrawMode()? [import]uid: 3007 topic_id: 2108 reply_id: 6390[/import]

Yes I do.

I narrowed it down to calling removeSelf on an object that has a physics body. If I comment out that line it no longer crashes.

But it seems to work fine in “normal” mode. [import]uid: 8434 topic_id: 2108 reply_id: 6397[/import]

removeSelf() on a physics object should work in general, but are you calling it on a collision listener? It may be that you’re trying to remove an object that’s still trying to resolve its collision?

(A crash is still a bug, but this is a way to narrow down the problem.) [import]uid: 3007 topic_id: 2108 reply_id: 6400[/import]

It’s being called in the enterFrame event. I’m moving a bunch of objects with static sensors in that event by setting their y values. When one moves off screen, I use removeSelf() to delete it. [import]uid: 8434 topic_id: 2108 reply_id: 6403[/import]

That’s the bug! I see it now, nice catch!

Specifically, if you call removeSelf() on an OFFSCREEN physics object WITH the physics wireframe rendering modes on, the Corona Simulator will crash. It’s the combination of all those things.

As a guess, it probably has something to do with our logic for automatically not drawing things that are offscreen, which makes the offscreen objects slightly “special” in the rendering chain.

Thanks for helping to narrow this one down! [import]uid: 3007 topic_id: 2108 reply_id: 6405[/import]

(Now logged as internal bug #1188) [import]uid: 3007 topic_id: 2108 reply_id: 6406[/import]

Glad I could help out! Any chance a fix for this will be in the next release? :smiley: [import]uid: 8434 topic_id: 2108 reply_id: 6407[/import]