crash in presentRenderbuffer:GL_RENDERBUFFER and/or GLES2VBVO::EnsureVerticesInited - ios

I am experiencing two random crashes, but they only seem to be occurring on the iPhone 4. All of our Android devices and any Apple device newer than an iPhone 4 does not crash. We recently started building for iOS, and have had working Android builds for over a year.
The iPhone 4 is on iOS 7.1.2
Unity is 4.5.5.f1
Xcode is 5.1.1
The phone was on iOS 7.0, and upgrading to 7.1 did not help. We also tried a build with Unity 4.5.5p5 and the issue still persists.
Both Crashes have this at the top of the call stack of the thread:
gpus_ReturnGuiltyForHardwareRestart
One of the crashes is in DisplayManager.mm:
- (void)present
{
if(surface.context != nil)
{
PreparePresentRenderingSurface(&surface, [[DisplayManager Instance] mainDisplay]->surface.context);
EAGLContextSetCurrentAutoRestore autorestore(surface.context);
GLES_CHK(glBindRenderbuffer(GL_RENDERBUFFER, surface.systemColorRB));
[surface.context presentRenderbuffer:GL_RENDERBUFFER];
if(needRecreateSurface)
{
RenderingSurfaceParams params =
{
surface.msaaSamples, (int)requestedRenderingSize.width, (int)requestedRenderingSize.height,
surface.use32bitColor, surface.use24bitDepth, surface.cvTextureCache != 0
};
[self recreateSurface:params];
needRecreateSurface = NO;
requestedRenderingSize = CGSizeMake(surface.targetW, surface.targetH);
}
}
}
Link to Xcode screenshot
The other is in the OpenGL library at:
GLES2VBO::EnsureVerticesInited(bool)
Link to Xcode screenshot

Related

iOS app crashes with Symbol Not Found HKVerifiableClinicalRecordQuery in xcode 13.3

I have an app that runs fine on iPhone iOS 15 but crashes on simulator iOS 13. The
call to HKVerifiableClinicalRecordQuery is wrapped in a #available block but the library tries to be uploaded at launch time:
Referenced from: /Users/johndoe/Library/Developer/Xcode/DerivedData/appHere-ebozeeuyrbpizofrvpxydtfbydkf/Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework
Expected in: /System/Library/Frameworks/HealthKit.framework/HealthKit
in /Users/johndoe/Library/Developer/Xcode/DerivedData/appHere-ebozeeuyrbpizofrvpxydtfbydkf/Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework
This is very similar but kind of old now: https://developer.apple.com/forums/thread/12110
All entitlements seem right as the same app without changes work fine in xcode 13.1 + iOS 13.
Apple release notes don't show anything special with HK so I wonder what could this be.
The snippet of code where the call is done is this:
func requestVerifiableHealthRecords() {
if #available(iOS 15, *) {
let healthStore = HKHealthStore()
let credentialTypes = ["https://smarthealth.cards#immunization"]
let dateInterval = DateInterval(start: .distantPast, end: .now)
let predicate = HKQuery.predicateForVerifiableClinicalRecords(withRelevantDateWithin: dateInterval)
let query = HKVerifiableClinicalRecordQuery(recordTypes: credentialTypes, predicate: predicate) {
// some code here
}
healthStore.execute(query)
}
}
But as I mentioned above, crash happens at launch time, this piece of code is never even close to being executed. The simulator shows the splash screen and nothing more. Debug navigator shows start then __abort_with_payload.
The concerning line is this one:
Expected in: /System/Library/Frameworks/HealthKit.framework/HealthKit
Why is even looking for a framework in MacOS, in any case, it should be looking it in xCode bundle and it shouldn't fail/crash.
I think the error is misleading, it must be something else but I still can't figure it out.
Found the issue for this one. Hopefully can help anyone with similar crash.
Select your crashing target
Select Build Phases tab
Expand Link Binary With Libraries and change Embed setting to be Optional for the offending framework. In this case HealthKit framework
Build again and crash should've been gone now.

Getting Error while upgrading to new Xcode 12

My App is using CoreLocation and CLLocationManager and is working fine in iOS 13 and iOS 12.
I have implemented new feature of Precise Location in iOS 14 using Xcode 12 and its working fine in iOS 14, iOS 13, iOS 12.
But When I execute ths Xcode 12 code in Xcode 11 version (Xcode 11.7) then I am getting error
Cannot infer contextual base in reference to member 'reducedAccuracy'
Value of type 'CLLocationManager' has no member 'accuracyAuthorization'
if #available(iOS 14.0, *) {
if authorizationStatus.accessLevel == .granted && locationManager.accuracyAuthorization == .reducedAccuracy {
return .locationAlwaysAllowPreciseLocationOff
}
if authorizationStatus.accessLevel == .denied && locationManager.accuracyAuthorization == .fullAccuracy {
return .locationDeniedPreciseLocationON
}
}
// MARK: iOS 14 location function.
#available(iOS 14.0, *)
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
// iOS 14 Location Delegate method, not available in iOS 13 version
}
and here the error is
Static member 'authorizationStatus' cannot be used on instance of type 'CLLocationManager'
As i Know Precise Location is feature of iOS 14 and its not available in below versions and "accuracyAuthorization", ".reducedAccuracy", ".fullAccuracy" is not available in iOS 13 versions.
My Question is how can i make my code run in Xcode 11 versions. I have already added the isAvailable check to check the device version.
Thanks in advance :)
No amount of #available or #available marking is going to help you in this situation.
Why not? Well, you're doing an unexpected thing: you are opening an Xcode 12 project in Xcode 11. Your code was compiled originally in Xcode 12, where iOS 14 is a thing. So it compiled successfully. But now you open the same project in Xcode 11, where iOS 14 is not a thing. Nothing about this environment has the slightest idea that it exists. Therefore, code that involves something unique to iOS 14 will not compile. If the compiler sees that code, you are toast.
So is all hope lost? Not quite! Suppose we were to hide the code from the compiler. If we do that — if we can arrange things so that, in Xcode 11, the compiler never sees this code at all — then we will be able to compile in Xcode 11.
Well, we can do that! We can use a compilation condition. All we need is some condition that we are allowed to check against, that will distinguish what version of Xcode this is. And there is such a condition — the Swift version.
So, we can write this, for example:
class ViewController: UIViewController {
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
#if swift(>=5.3)
let status = manager.authorizationStatus
print(status.rawValue)
#endif
}
}
That code compiles in both Xcode 12 and Xcode 11, because in Xcode 11 the compilation condition fails, and the compiler never even looks inside the #if block.
In fact, we can provide an alternative version of the code, to be used in Xcode 11. In order to make this work as we desire, we will also have to restore your #available check, because we have to make the project's deployment target iOS 13, and the Xcode 12 compiler will complain if we don't protect the iOS 14 code:
class ViewController: UIViewController {
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
#if swift(>=5.3)
if #available(iOS 14.0, *) {
let status = manager.authorizationStatus
print(status.rawValue)
}
#else
let status = CLLocationManager.authorizationStatus()
print(status.rawValue)
#endif
}
}
That code compiles and behaves correctly in either Xcode 11 or Xcode 12. Do you understand why? Let's review, because it's a bit tricky.
In Xcode 11, the whole #if section is never seen by the compiler. It sees only this:
let status = CLLocationManager.authorizationStatus()
print(status.rawValue)
That's good iOS 13 code, so all is well.
In Xcode 12, the whole #else section is never seen by the compiler. It sees only this:
if #available(iOS 14.0, *) {
let status = manager.authorizationStatus
print(status.rawValue)
}
That's good iOS 14 code, because, even though our project's deployment target is iOS 13, we have calmed the compiler's nerves by guaranteeing that this code won't execute in iOS 13 (where it would crash if it did execute).
Having said all that, the real answer is: don't. Everything I just did is way too much trouble! Once you've written code under Xcode 12, don't try to open that project in Xcode 11. That's not the way to test for backward compatibility.

Why iOS 14 ATT Prompt Won't Work on Simulator?

I am trying to make a plugin for my unity project to call new ios 14 ATTracking. It doesn't prompt on screen, why ? I am not getting any error and i know that code goes into the if statement. Trying On Simulator, maybe thats why it doesn't work ?
+(void)requestAttPermission:(NSString*)callback
{
if (#available(iOS 14, *)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status)
{
UnitySendMessage("SomeGameObject", [callback UTF8String], "");
}
}
}
Apparently, it works on the iOS 14 simulator. What I did wrong was that I thought that the AppTrackingTransparency.framework was already added, but it wasn't.
After I added that framework (in Xcode -> Build Phases -> Link Binary With Libraries) it worked.

Cannot build source in XCODE 8 iOS 10

I have developed iOS application using Swift 2.3. and I have put the application to the app store in review process, apparently they have rejected it due to crash in iOS 10 .
Then in order to fix it I have downloaded the Xcode 8 and tried to build the app without converting code in to swift 3 using legacy setting
But I couldn't build the app. There was few compile errors in pods that I have used. (Alamofire framework)
error :- and there will more
private func trustIsValid(trust: SecTrust) -> Bool {
var isValid = false
var result = SecTrustResultType(kSecTrustResultInvalid)
let status = SecTrustEvaluate(trust, &result)
if status == errSecSuccess {
let unspecified = SecTrustResultType(kSecTrustResultUnspecified)
let proceed = SecTrustResultType(kSecTrustResultProceed)
isValid = result == unspecified || result == proceed
}
return isValid
}
So I did a small digging apparently Alamofire has released a new version for Xcode 8 so i have put that version, apparently I can't integrate that version in to my source code since it's in Swift 2.3.
Can someone help me to get over with this issue, problem was I can't release the app to App store since there is a crash in iOS 10 and I can't check it since I don't have iOS 10.

UIViewController reported as responding to addChildViewController: on iOS 4

Has anyone else encountered this? The following code reports "YES" when running on the iOS 4 simulator but according to the Apple docs the method addChildViewController is only available on iOS 5 and later. This doesn't seem like the correct behavior, is this a bug?
if([UIViewController instancesRespondToSelector:#selector(addChildViewController:)]) {
NSLog(#"YES");
} else {
NSLog(#"NO");
}
I think this is a bug. Calling the addChildViewController seems to run without any warning or error too.
I wrote the following viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
MyChildView *aChildViewController = [[MyChildView alloc] initWithNibName:#"MyChildView" bundle:nil];
// Do any additional setup after loading the view, typically from a nib.
SEL mySelector = #selector(addChildViewController:);
if([UIViewController instancesRespondToSelector:mySelector] == YES) {
NSLog(#"YES addChildViewController:");
[self addChildViewController:aChildViewController];
} else {
NSLog(#"NO addChildViewController:");
}
if([UIViewController instancesRespondToSelector:#selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)] == YES) {
NSLog(#"YES automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers");
} else {
NSLog(#"NO automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers");
}
}
In the iOS 4.3 Simulator I see following output. Both messages are restricted to IOS 5.0 and higher. It appears addChildViewController is responding in the 4.3 simulator incorrectly. I don't have 4.3 device to test on an actual device.
2011-11-18 09:55:12.161 testViewFunctionality[873:b303] YES addChildViewController:
2011-11-18 09:55:12.162 testViewFunctionality[873:b303] NO automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
In the iOS 5.0 Simulator both respond which is correct behavior.
2011-11-18 09:59:31.250 testViewFunctionality[932:f803] YES addChildViewController:
2011-11-18 09:59:31.252 testViewFunctionality[932:f803] YES automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
I'm using XCode 4.2 on Lion. When I look through UIViewController.h on the 4.3 Simulator's framework there is no mention of addChildViewController: or automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers but the only SDK included is 5.0.
I suppose that if you wanted to be cautious you could test the running iOS version on the running device. See How to check iOS version?
Yes, that is a bug and it will never be fixed. As a workaround, instead of checking for the availability of addChildViewController: method, you can check for removeFromParentViewController method. The latter is not available before iOS 5.0.
It's quite possible this method existed in previous version of iOS, but it just wasn't public yet. Apple usually prepends private methods with an underscore but it has been known to do this kind of thing before.

Resources