Inexplicable Fence Hang

Hello, My App is getting a Fence hang right after install in a specific scenario.

Issue1: I attempted to follow the directions, tried to symbolicate the file etc. however did not have much luck.

I was able to pinpoint the lines of code where the hang seems to occur. I did this using simple print and comment out/uncomment blocks of code related to the specific scenario. I was able to do so as, not much is happening on the Main thread in this scenario .

Issue 2: The following lines of code ( modified var etc. ) seem to cause the hang. Commenting them out gets rid of the hang across devices, while online/offline etc. I am not sure if I need to use a framework other than AVFoundation.

Note:

  1. The file extension is mpg
  2. The music files are static ( included in the Bundle ) and not accessed from user's playlist etc.

import <AVFoundation> var plyr : AVAudioPlayer?

    let pth = Bundle.main.path(forResource: "MusicFileName", ofType: "mpg")!
    let url =  URL(fileURLWithPath: pth)
    do [{](https://www.example.com/)
         plyr = try AVAudioPlayer(contentsOf: url)
         plyr?.prepareToPlay()
         plyr?.play()
     } catch {
        // print error etc.
     }

Thanks in advance. I would appreciate some help! Close to submission :)

Answered by playbrainiacs in 802563022

Wav file works!!!

One of the older posts about this topic mentioned use of wav file instead. I tried that and it worked!!!

Apparently mp3 being compressed coupled with use of AVFoundation may have something to do with it but still baffling, as I am simply playing music from statically included Bundle files.

Anyway, onto the rest of testing and debugging hangs if any! 😬

I don’t really understand what you mean by “Fence hang”. Based on your description, it sounds like just a hang. Can you elaborate on what the “Fence” bit means?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks. It summarizes on the overlay as "Fence Hang". It refers to ( I think )

"Event: Blown CA Fence Hang" per the Spindump file.

I have no idea why there is some embedded "[ ] (https://www.example.com/) in my original post above. I don't remember adding that indeed no idea what that website is. I am unable to edit to remove that junk. Cleaned up code is :

import <AVFoundation> var plyr : AVAudioPlayer?

let pth = Bundle.main.path(forResource: "MusicFileName", ofType: "mpg")!

let url = URL(fileURLWithPath: pth)

do {

     plyr = try AVAudioPlayer(contentsOf: url)
     plyr?.prepareToPlay()
     plyr?.play()

} catch {

    // print error etc.

}

Ugh! noticed a typo.

  1. File extension is mp3
  2. Also noticed I had included a same name file with a different extension in the bundle . I removed the reference, just in case .

No luck yet. Should I be using a different Audio framework?

Should I be using a different Audio framework?

AVAudioPlayer seems like a reasonable option to me, but I’m not really an audio person.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Wav file works!!!

One of the older posts about this topic mentioned use of wav file instead. I tried that and it worked!!!

Apparently mp3 being compressed coupled with use of AVFoundation may have something to do with it but still baffling, as I am simply playing music from statically included Bundle files.

Anyway, onto the rest of testing and debugging hangs if any! 😬

Inexplicable Fence Hang
 
 
Q