Game Development Community

Schedules and Behaviors not working in iPad3 - works in sim and iPhone4.

by John Vanderbeck · in iTorque 2D · 04/29/2012 (6:04 pm) · 33 replies

I have tried using both Behaviors with onUpdate() as well as schedules, both global and object based.

Something very odd is going with them. The exact same code, compiled and run produces different results on different devices.

On the iOS simulator in iPad or iPhone mode, the schedules and behaviors work.
On iPhone 4 the behaviors and schedules work
On iPad3 neither work.

Does anyone have any flapping clue why this might be or even where to look?!
Page«First 1 2 Next»
#21
05/19/2012 (4:46 pm)
Is PUAP on/off with this bug? I've tried removing the PUAP code from Cannibal Cookout but it just causes the game to crash in random places so I've kept it on. Also, we STILL have to compile without optimisation.

John/Chris, have you checked the xCode optimisation level (-O) - we have to use -O0 ?
#22
05/19/2012 (5:12 pm)
I experienced it with PUAP off. I can't recall if I tested it with PUAP on. As far as compile flags, whatever the default is is what i've been using. I'm not that familiar with Xcode so not sure how to change that.
#23
05/19/2012 (8:29 pm)
Oddly when I tried John's fix, it would cause a very jumpy / broken behavior with my game. But if I cast the absolute time as a double, then the code worked. IE:

double absTime = (double)mach_absolute_time();
Duration durTime = absTime * absolute_to_millis;

I don't know if casting the unsigned mach_absolute_time back to signed did the trick or what.... but I uploaded and update to the app store. Hopefully I'll get some users telling me that it did / didn't fix the bug.
#24
05/20/2012 (5:10 am)
This is the final code that I had ended up with:

U32 Platform::getRealMilliseconds()  
{  
      
    mach_timebase_info_data_t info;  
    if (mach_timebase_info(&info) != KERN_SUCCESS) return -1.0;  
    uint64_t absTime = mach_absolute_time();  
    uint64_t nanos = absTime * info.numer / info.denom;      
    uint64_t durTime = nanos / 1000000;  
    //Duration durTime = absTime * absolute_to_millis;  
    U32 ret;  
    ret = durTime;  
  
    return ret;  
}
#25
07/21/2012 (8:15 am)
Final Code works great! Not sure why this bug didn't effect my other apps. One is even universal. I'm guessing the extent I use schedule is much more in my current project. Was having weird results and remembered this post. In my case iPad 1 worked perfectly and iPhone 4S would almost lockup and physics would not work. iPad 3 would stutter for about 30 secs and seem to start working only to lock up 10 seconds later and crash. Strange shit. Thanks John!!! You have fixed 2 big problems I have run into.

What products have you put out? I need to pay you back in some capacity.
#26
07/21/2012 (9:51 am)
Glad I could help. I think its something about how later devices handle time, which causes the overflow.

Maybe now Mich will believe me :)
#27
07/21/2012 (9:52 am)
Quote:
What products have you put out? I need to pay you back in some capacity.

Nothing yet. I'm still working on my first iOS game, GraviTile. Really just hung up in menu design and art at the moment. Thinking i'm soon just going to move ahead regardless of what my artist says :p
#28
07/23/2012 (2:47 am)
We think we are now seeing this issue on Cannibal Cookout. Apple have rejected an update saying that it stops on the loading screen at 1% (our first use of schedule) - this is on the iPad 3 AND iPhone 4 running 5.1.1.

Going to try John's fix as we can't reproduce on any of our devices.
#29
07/25/2012 (3:02 pm)
Our app got approved after applying John's fix.

@GG - you might need to roll this into 1.5.2?

@John - thanks for the fix!
#30
07/25/2012 (4:27 pm)
You are welcome. I'm just glad i'm not crazy after all :)
#31
07/29/2012 (9:28 am)
@John V. Nope not crazy ;) I thought you were before it effected me as well haha. Be sure to let us know when you release your product. I'll do my best to promote on my site, twitter and Facebook.
#32
09/13/2012 (7:25 am)
I further updated the code, so that
1. it calls mach_timebase_info() only once
2. it returns 0 on the first call, and will overflow in 49 days since the first call to this function.


U32 Platform::getRealMilliseconds()
{
    static mach_timebase_info_data_t info;
    static bool data_loaded = false;
    static U32 first_ret = 0;
    if( ! data_loaded)
    {
        if (mach_timebase_info(&info) != KERN_SUCCESS)
            return -1.0;
    }
    //get duration in miliseconds.
    uint64_t absTime = mach_absolute_time();
    uint64_t nanos = absTime * info.numer / info.denom;
    uint64_t durTime = nanos / 1000000;
    //convert it to U32
    U32 ret = durTime;
    //now record the first call to this function,
    if(! data_loaded)
        first_ret = ret;
    data_loaded = true;
    //the return value starts from zero, will overflow in 49 days since the first call
    ret -= first_ret;
    return ret;
}
#33
09/13/2012 (6:05 pm)
I had a recent app submission get rejected because it failed to start on iPad3. The way I got around this was to change optimizations to -O0 (that's dash 'o' zero). That fixed it and I guess the app launched.

Unfortunately I don't have an iPad3 but I'm guessing there's some underlying difference.
Page«First 1 2 Next»