Using newRect for background causes crashes with Director

OK, this makes no sense to me…it’s very strange, but I FINALLY figured out why my own application was crashing/hanging on real hardware but the Director 1.2 demo app worked fine.

I found a single change to the Director 1.2 app will reproduce this problem for me.

Go into the screen2.lua file and change the line:

[lua]local background = display.newImage(“images/background2.png”)[/lua]

to this

[lua]local background = display.newRect( 0, 0, display.contentWidth, display.contentHeight)
background:setFillColor( 0,0,250)[/lua]

That’s it. Just changing the background from an image to a solid blue rectangle.

Now, build this and put it on actual hardware. For this test I was using an original iPod touch running iOS 3.1.3. Also tested on Android with a DroidX running 2.2.

If you repeatedly tap the moveFromLeft button and then tap the screen to return and keep doing this 10-20 times, eventually the app will either hang or just exit

Now, you’ll notice that in Screen2, the background is where the addEventListener is being added. This is important. If you simply add a rectangle to the screen, but still add the event listener to the IMAGE, then it will still work. It’s adding the touch listener to the RECTANGLE that causes the problem.

Maybe it’s because of a difference in how images are cached internally to Corona. I have no idea. Maybe somebody else can explain why changing the background from an image to a rectangle would make such a big difference on actual hardware.

(remember: works fine in the Simulator. You need to test this on real hardware!)
[import]uid: 12529 topic_id: 6743 reply_id: 306743[/import]

Sigh…this is being a real bitch to figure out.

It’s not this simple. I created a standalone test program that just had two screens with Rectangles on them (with touch events) and I was able to flip between them just fine.

It’s something more complex. Maybe when you start adding more resources to the screen. If it’s a garbage collection timing issue, then it would make sense that the more stuff on the screen, the more likely to show a problem.

But I’m really having a heck of a time really pinning this down to something simple I can test (outside of my own app, or the modified Director 1.2 demo as patched above)

The problem with all of this is that it causes huge stability and crashing problems in real applications. And it’s stuff that doesn’t show up as a problem in the Simulator. And that makes this a real problem for developers. You spend weeks getting something complex in the Simulator only to find that it crashes the phone. And by that time, debugging it is a real pain.

We really don’t want Corona to get a bad reputation from users as being unstable apps. I’ve been programming desktop apps for over 20+ years and I’ve rarely run into something this flaky and hard to reproduce. It’s driving me nuts. [import]uid: 12529 topic_id: 6743 reply_id: 23530[/import]

Well, after removing all of my Rectangle backgrounds and replacing them with images (something that I was eventually going to do anyway), my test app now works great on the old iOS 3.1 iPod device.

But today I did an Android build and it completely doesn’t work on the DroidX. The Director scene transitions don’t happen at all. And tapping a button to do the transition causes the entire app to hang.

I will try the Director demo app later today, but I must say that I’m about ready to give up completely on Corona. I know this probably isn’t the best forum to vent my frustrations, but:

  1. Maybe “subscribers” are getting better support, but I don’t see much (if any) response to bug reports or other issues in these forums from Ansca. This really worries me. Like Corona is growing beyond the ability of Ansca to properly support it. Or is the support all hidden in the subscriber-only forum?

  2. Biggest problem: The “Simulator” is not a simulator. Stuff that works perfectly fine in the simulator does not work on actual devices. And once you fix code to work on one device (like iPhone), then it doesn’t work on other devices (Android). I cannot afford to buy every device that I want to build my app for, and if I can’t trust the simulator, that removes all of the advantages of using Corona in the first place.

I know I’m not alone with this. I see dozens of posts about problems with stability and issues with physical devices vs the simulator and as in (1) I’m not seeing any official replies to these issues. Given these issues, I’m not sure I want to pay for a subscription.

I feel like I’m using a Beta product, when I really need a stable development platform. I’ve got enough work to do with my own app and debugging it without wasting my time trying to determine why using a Rectangle in Director causes the iPhone to crash on hardware and why the working iPhone code fails to work on Android. It’s VERY frustrating.

Sorry for the vent. This is really an issue for Ansca and Corona and not for the creator of the Director class. [import]uid: 12529 topic_id: 6743 reply_id: 23757[/import]

I hear what your saying and I aggree with a few of your points. From my experience Corona has been solid as a rock and what’s displayed in the simulator works fine on devices however complex projects have become flakey since using Director.

Projects work fine in the simulator but on the device give unexpected results or crashes. I’ve been putting it down to my lack of understanding which it probably is as I know I should go through director class and make sure I understand every detail but I’ve been lazy since using Corona.

All my code works solidly on it’s own but with director class I think memory management goes wonkey on the device and with auto garbage collection this doesn’t help. I can understand why apple put in a dealloc method for iOS and Objective C.

Other than this set back the support of the Corona community has been great and bug fixes have been fixed in a timely fashion. [import]uid: 33866 topic_id: 6743 reply_id: 24013[/import]

I’m going to work on this more this week. I really want to figure out why using Director makes apps so flaky. I am also going to have an email discussion with Carlos about this.

My guess is that the reason Director makes apps flaky is because Director is trying to “dispose” of a module. I think this is a good design goal so that you only have one Scene in memory at a time. But I think the current cleanup/garbage collection code in Director is somehow the heart of the stability problems.

I think Director has uncovered an issue with the underlying Corona system. I don’t see anything wrong in theory with the code that is currently being used in Director 1.2. But obviously it causes great difficulty on various hardware, even though it works fine in the simulator.

I’ll post to a new thread when I really figure this out. Even if I don’t end up using Director in my app, I really want to know why it’s causing these problems so that Corona itself can be improved. [import]uid: 12529 topic_id: 6743 reply_id: 24521[/import]

We found that for really heavy screens we had to remove the transition calls which solved the stability problems on iphone. We are still running into issues on the android hardware though. Any progress on this lately?
[import]uid: 39480 topic_id: 6743 reply_id: 36996[/import]