SKAudioNode is THROWING and it never did before updating Xcode 13.4 - skaudionode

I coded a fully operational video slot machine that ran perfectly prior to updating recently to Xcode 13.4. Now, SKAudioNode is causing trouble. It used to work without problems, but now, the first use of SKAudioNode anywhere in my code gives a "throwing -10878" error. The sound still plays and the app doesn't close, but every once in a while everything temporarily slows to a crawl as if the game interrupts are overloaded (which never happened before now).
I've traced the problem down to the addChild line. Keep in mind, this always worked before now.
myMusic = SKAudioNode(fileNamed: "myMusicFile")
myMusic.autoplayLooped = true
addChild(myMusic). <--- THROWS HERE

Related

MPMediaLibrary.requestAuthorization not responding on Xcode 10.2 simulator

I just noticed that after having updated Xcode to version 10.2.1, I'm unable to see the permission request for Library and Apple Music when launching a couple of projects of mine on the simulator.
Debugging, I realised that the authorization request call goes unanswered
MPMediaLibrary.requestAuthorization { status in
// switch on status and handle it - never gets there
}
I didn't change anything in the code or configuration of my projects, and I'm very sure that this wasn't happening with previous versions of Xcode.
Just for the record, everything works fine on a real device.
Does anybody have any idea?
Am I the only one who's experiencing this?
Looks like it doesn't work on the simulator. It now just hangs, and the closure is never executed.
It did, at one time, but I guess that it no longer does.
Sort of unsurprising, as the basic media capabilities aren't really supported on the simulator anyway.
I have tested my code on device, and verified that it works, but it is annoying (not a showstopper) that it doesn't work on the simulator.

iOS 10 with XCode 8 GM caused NSUserDefaults to intermittently not work

NOTE: I have seen many other posts on Stack Overflow about NSUserDefaults being renamed to UserDefaults in Swift or not working on simulator until a restart. This is not a duplicate by anyway. Many of the questions SO is tagging against is from 4 years ago. My question is specific to iOS 10 from this year as this has always worked in older versions. I have mentioned in my question already that my question is not a duplicate of those questions as those were simulator bugs in swift and my issue is on device objective C bug. Please read the questions before marking as duplicate
My issue is different as I am able to reproduce this on objective C and on physical device itself.
I created a brand new project from scratch for this test. I placed this code in the viewDidLoad of a view controller:
if (![[NSUserDefaults standardUserDefaults] valueForKey:#"checkIfInitialized"]){
NSLog(#"setting checkIfInitialized as not exist");
[[NSUserDefaults standardUserDefaults] setValue:#"test" forKey:#"checkIfInitialized"];
[[NSUserDefaults standardUserDefaults] synchronize];
self.view.backgroundColor=[UIColor redColor];
self.mylabel.text=#"NSUserDefaults was NOT there, try running again";
} else {
NSLog(#"checkIfInitialized exists already");
self.view.backgroundColor=[UIColor blueColor];
self.mylabel.text=#"NSUserDefaults was already there this time, try running again";
}
Now if I run the app about 10 times, few times it finds the checkIfInitialized and sometimes it doesn't. No exact number on how many times it fails as it might work 3 times then fail next 2 times then work 4 times and fail once and so on.
Now something I have noticed (not 100% sure though) that the issue only seems to happen when I am testing connected via Xcode. If I run by launching the app by clicking the app icon on device without Xcode, then it seems to work fine but I can't be 100% sure.
I noticed this error occur sometimes:
[User Defaults] Failed to write value for key checkIfInitialized in CFPrefsPlistSource<0x1700f7200> (Domain: com.xxxx.appname, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null)): Path not accessible, switching to read-only
I have this very simple project on my dropbox if you want to test it out.
I would suggest testing about 10-15 times to reproduce this issue.
https://www.dropbox.com/s/j7vbgl6e15s57ix/nsuserdefaultbug.zip?dl=0
This works completely fine on iOS 9 so definitely something to do with iOS 10.
EDIT
Bug logged: 28287988
Response from apple DTS team:
First off, you should first determine whether standardUserDefaults or
valueForKey is failing. My guess is that “standardUserDefaults” is
returning NULL and, if that’s the case, then that’s something you
should be guarding against generally. Notably, standardUserDefaults
will return NULL if the preference file is encrypted in the
environment the app is currently running in (for example, preferences
is set to “NSFileProtectionComplete” and the app is running in the
background). That shouldn’t be an issue for standard foreground-only
apps, but it’s something to be aware of anyway.
It’s very likely that Xcode is actually inducing the problem here.
Xcode vastly complicates the app launching environment in a way that’s
VERY different than a standard app launch. My guess is that this is
basically being triggered by Xcode’s timing inducing an an expected
situation during the app launch, but if you want a more formal test of
that try setting a single breakpoint in applicationDidFinishLaunching
and continuing in the debugger as soon as you hit it. My guess is
just adding that disrupts the timing enough to stop the problem from
happening. Sort of. It’s iOS 10 only in the sense that iOS 9 will
never print that log message, but that’s because the log message was
added in iOS 10. The code itself is similar enough to iOS 9.3 that I
suspect exactly the same behavior is (at least in theory) possible in
iOS 9.
Yes, this is definitely a reproducible bug.
It happens with the GM release of Xcode 8 and iOS 10.
It is not the linked question referring to Swift.
It is not the linked question referring to beta versions of the Simulator.
The bug happens on devices and on the Simulator. It is intermittent: saving will work six times and then fail. Unlike you, I did not get the "failed to write key" message.
The bug also occurs when operating directly on the device without Xcode. This is in fact how I discovered it.
You should report a bug to Apple, especially since you have a short program that will reproduce it. I will do the same.
One key difference: In my case the failure is in writing the default. The previously written value remains in NSUserDefaults. Sometimes one key is successfully written while another is unchanged.
A similarly very intelligent DTS response from my own support request. Basically, killing using Xcode is more murderous than anything that would naturally happen on the device (even the double-Home-click-and-upswipe method) and since everything is abruptly crashed when Xcode halts it, the lazy writing of NSUserDefaults can fail, or be only half completed.
And indeed, pure on-device testing of the app, without Xcode involved, shows that everything does get correctly written to NSUserDefaults when the app is terminated.
I have closed my own bug report.

Address Sanitizer with SpriteKit

I'm trying to diagnose my app with Address Sanitizer.
Although the app runs quite smoothly and I only wanted to get further checks regarding the memory alloc etc. I get the following error when I run the app.
It's my first time using Address Sanitizer but as far as I concerened it needs to point out to one of the developer's line of code.
It seems to me like it crashes at internal libary.
Any ideas or suggestions?
Apparently the problem was that I tried to run the game on an iPad with iOS8.0.
On iOS >= 9.0 it works fine.

Passing nil into offset, after iOS 9 update, freezes app (Null passed to a callee that requires a non-null argument)

I have a Sprite Kit game in the app store that worked perfectly before the iOS 9 update. With my iPhone updated to iOS 9, the game now freezes forever when the player loads a scene that contains this code:
[SKConstraint orientToNode:bodyB.node offset:nil]];
Getting rid of this from the source code allows the game to work just like before. However, I need this line of code for a specific in-game function.
Xcode is throwing out an error beside this line of code that says this: "Null passed to a callee that requires a non-null argument". Fair enough. But then what kind of argument do I pass into the "offset:"? I've tried [SKRange rangeWithNoLimits] but the game still freezes. Any idea what to do?

App crashes without reason with xCode 4

Something weird is going on here.
My app crashes on this line of code:
int end = NSMaxRange(endRange);
but I don't get any error message, and everything is fine: endRange. The app just freezes in the iPhone and that's it.
1.
The weird thing is that the same code was working before, and I've reversed from repository to see what's wrong but it still doesn't work.
2.
Also xCode removes the breakpoint every time the app crashes. I add it again, I run the app, I step over, the app crashes and Xcode removes the breakpoint.
3.
I've cleaned the build, restarted xCode, restarted the iPhone, removed the app from the iPhone. Same issues.
4.
If I don't use breakpoints, the app doesn't crash, but the code right after that line is "skipped", but it was working before. At least the app doesn't freeze without breakpoint.
What the hell ?
I've had similar problems with the debugger in the past too. Try switching from LLDB back to GDB (From the Product / Edit Scheme menu). I've found LLDB to do exactly what you are describing with breakpoints.

Resources