Crash in iPad with iOS 3.2

Hi!

I just found that SDL is crashing in the iPad simulator for iOS 3.2 but not for iOS 4.2 or over when compiling with Xcode 4.0.2.
The Xcode debugger points to line 127 in video/uikit/SDL_uikitopenglview.m as the line that triggers the crash.
On those lines one can find:

Code:
/* Use the main screen scale (for retina display support) */
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
self.contentScaleFactor = [UIScreen mainScreen].scale;

I believe the problem to be that -contrarily to what Apple docs appear to state- the “scale” selector is supported in iOS 3.2 in the iPad, but contentScaleFactor is not.
I’m no expert in Objective-C, but I believe the following code to be more correct (it doesn’t crash for me):

Code:
/* Use the main screen scale (for retina display support) */
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [self respondsToSelector:@selector(contentScaleFactor)])
self.contentScaleFactor = [UIScreen mainScreen].scale;

The same check is being performed in line 155 so I imagine it will crash there, too.

I’ve filed a bug with this same info in Bugzilla:
http://bugzilla.libsdl.org/show_bug.cgi?id=1239

I’m speaking from memory at the moment, but I think you want to use
contentScaleFactor exclusively; don’t use scale.

Basically:

float my_scale_factor = 1.0;
if([your_ui_view respondsToSelector:@selector(contentScaleFactor)]
{
my_scale_factor = [your_ui_view contentScaleFactor];

}

-EricOn Thu, Jun 30, 2011 at 7:07 PM, josebagar <joseba.gar at gmail.com> wrote:

**
Hi!

I just found that SDL is crashing in the iPad simulator for iOS 3.2 but not
for iOS 4.2 or over when compiling with Xcode 4.0.2.
The Xcode debugger points to line 127 in video/uikit/SDL_uikitopenglview.m
as the line that triggers the crash.
On those lines one can find:

Code:

    /* Use the main screen scale (for retina display support) */
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
            self.contentScaleFactor = [UIScreen mainScreen].scale;

I believe the problem to be that -contrarily to what Apple docs appear to
state- the “scale” selector is supported in iOS 3.2 in the iPad, but
contentScaleFactor is not.
I’m no expert in Objective-C, but I believe the following code to be more
correct (it doesn’t crash for me):

Code:

    /* Use the main screen scale (for retina display support) */
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] &&

[self respondsToSelector:@selector(contentScaleFactor)])
self.contentScaleFactor = [UIScreen mainScreen].scale;

The same check is being performed in line 155 so I imagine it will crash
there, too.

I’ve filed a bug with this same info in Bugzilla:
http://bugzilla.libsdl.org/show_bug.cgi?id=1239


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Sorry, I didn’t explain myself correctly.
The crash occurs in SDL code (here (http://hg.libsdl.org/SDL/file/c1ed57cbfd66/src/video/uikit/SDL_uikitopenglview.m)). I’m working with an interpreted game engine built on top of SDL and the crash occurs when setting the video mode, I’m not writing any Objective-C code myself.

Joseba

To say it in other words: just downloading the SDL source code from HG and compiling and running the testsdl scheme in the ipad 3.2 simulator crashes.