Posts

Post not yet marked as solved
1 Replies
727 Views
On iPadOS13 all "AVAudioPlayerNodes" that are attached to an "AVAudioEngine" are over-released after a "Media Service Rest".My application uses the "AVAudioEngine" similar to the "AVAudioEngine3DAudioExample".When I reset the media service (settings>developer>reset media service) my application receives an "AVAudioSession.mediaServicesWereResetNotification". When my app receives this notification, the app reattaches the player nodes to a new AVAudioEngine.Like this example from "AVAudioEngine3DAudioExample" ( ~ line 438).// Example form AVAudioEngine3DAudioExample - (void)createEngineAndAttachNodes { _engine = [[AVAudioEngine alloc] init]; [_engine attachNode:_environment]; [_engine attachNode:_launchSoundPlayer]; for (int i = 0; i < _collisionPlayerArray.count; i++) [_engine attachNode:[_collisionPlayerArray objectAtIndex:i]]; // <- Crash } // Example in Swift as I use it in my app func createAVAudioEngineAndAttachNodes() { // Create a new engine self.avAudioEngine = AVAudioEngine() self.avAudioEngine.attach(self.avAudioEnvironmentNode) // Attach all nodes. for player in self.allAudioPlayers { self.avAudioEngine.attach(player)// <- Crash } }Crash: EXC_BAD_ACCESS (code=1, address=0x0) #0 0x0000000187538240 in objc_retain () #1 0x00000001944b83a8 in -[AVAudioPlayerNode didAttachToEngine:] () #2 0x00000001944c4690 in AVAudioEngineImpl::AttachNode(AVAudioNode*, bool) () #3 0x00000001944c7dcc in -[AVAudioEngine attachNode:] () #4 ....I'm using swift 5 and the code works perfectly on iOS12 and macOS. I assume the media reset somehow destroys the AVAudioPlayerNode because it crashes when the AVFoundation framework trys to retain the audio player.Can someone confirm this issu or provide a workaround?
Posted Last updated
.
Post marked as solved
5 Replies
1.7k Views
Hi, in iPadOS Beta 13.1 the behavior of MTKViewDelegate.mtkView( MTKView , drawableSizeWillChange: CGSize ) is different to iOS 12.4 and earlier.The following example code is called by the MTKView each time the view's drawable changes. The code is used by the iOS and the macOS version of my game.class Delegate: MTKViewDelegate { public func mtkView(_ view: MTKView, drawableSizeWillChange drawableSize: CGSize) { // Print drawable size. print.("\(drawableSize.width) x \(drawableSize.height)" ) } }- macOSWhen the user resizes the MTKView this code prints the view's pixel size.500 x 300 510 x 308 516 x 316 518 x 320- iOS 12.4During launch on an iPad mini 2,4,5 (I tested several devices). The game supports landscape mode only and requires fullscreen.1536 x 2048 2048 x 1536The delegate is called twice. The first time the drawable size is the size of the iPad's screen in portrait mode. Then the app changes to landscape mode (this is forced by iOS because I set the landscape mode flag in the info.plist) and the delegate is called again with the same dimensions yet in landscape mode. This means the dimensions are just flipped because the iPad's physical screen size didn't change.So fare this is the behaviour I expected according to the documentation.- iOS 13.1 BetaDuring launch on an iPad mini 5.1536 x 2048 2731 x 1152Notice the second time – in landscape mode – the drawable size is different. The drawable size doesn't match the screen size. The width is larger than the screen and the height is to small.Now my question: Is this a bug or a feature?Do I need to enable something in iOS & iPadOS 13 to force the MTKView to use the native screen size in landscape mode?Maybe an Apple engineer could help.Thanks!
Posted Last updated
.