Possible crash when loadNibNamed on jailbreak devices [UIDeviceRGBColor superview]: unrecognized selector

两盒软妹~` 提交于 2019-12-08 02:25:39

问题


My code looks like this:

CGRect screenRect = [[UIScreen mainScreen] bounds];
SomeView *infoView;
if(screenRect.size.height != 568.0){
    // iPhone 5/5s users crash in the next line
    infoView = [[[NSBundle mainBundle] loadNibNamed:@"SomeViews" owner:self options:nil] objectAtIndex:1];  
}else{
    infoView = [[[NSBundle mainBundle] loadNibNamed:@"SomeViews" owner:self options:nil] objectAtIndex:0]
}

However, I get some crash reports from Crashlytics for iPhone 5/5s users as comment in the above code.

I am surprising that the height is NOT 568 for 5/5s since my app only supports Portrait orientation. I have hundreds of active users and only 12 crashes happened on 4 users.

And even if a iPhone 5/5s device load the wrong nib(for 3.5inch screen), it should not cause crash. (I just tested.)

http://crashes.to/s/1ddc169b801

Crashlytics also shown me that 90% of the crashes are on jailbreak devices, which makes me wonder that if jailbreak devices can change this value in any way?

Fatal Exception: NSInvalidArgumentException
-[UIDeviceRGBColor superview]: unrecognized selector sent to instance 0x14732db0

0
CoreFoundation  
__exceptionPreprocess + 130
1
libobjc.A.dylib 
objc_exception_throw + 38
2
CoreFoundation  
-[NSObject(NSObject) doesNotRecognizeSelector:] + 202

...

22
UIKit   
-[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 138
23
Banck   
BKAddRecordPagingViewController.m line 244 // line 244 is loadNibNamed
-[BKAddRecordPagingViewController viewDidLoad]

The crash report link shows the reason but I can't figure out why since I use only built-in UILabel, UIImageView, UITextView in the nib file.

Can anyone give me some advice to better check and if using 4 inch screen on jailbreak devices? The second question is that what caused the crash inside loadNibNamed?


回答1:


I suspect the Cydia Tweak "Eclipse" has an overrelease bug. (Eclipse.dylib is listed in your crash trace)

An instance of UIView from your NIB is being released, and the memory reused for a UIDeviceRGBColor instance.

See if you can repro with the Cydia Eclipse add on? You could trace your allocations with Instruments.




回答2:


Use UIScreen mainScreen

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}

I think it does not have anything to do with jb.




回答3:


Suggestion 1:

  • Do not equate the float with 568.0f. Just check if it is bigger than 567 and less than 1024

Suggestion 2:

  • This codebase has a very direct approach to detect various iOS devices. -- https://github.com/froztbytes/UIDeviceHardware


来源:https://stackoverflow.com/questions/21989412/possible-crash-when-loadnibnamed-on-jailbreak-devices-uidevicergbcolor-supervie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!