AVPlayerItem seekToPosition: sometimes seeks to the wrong place then plays silent audio until it catches up.

Originator:padraig.kennedy
Number:rdar://33061712 Date Originated:June 29 2017, 1:32 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 11
Classification: Reproducible:Sometimes
 
Area:
Audio

Summary:
Attached:
1. a project that can reproduce the issue, though it takes a few tries.
2. sysdiagnose logs taken within a minute of the bug happening

In the following setup, seekToPosition occasionally jumps to the wrong place and plays silent audio until it catches up to where it should have been.

Note: 
- This is reproducible even with the toleranceAfter:toleranceBefore: version of the method.

Steps to Reproduce:
- Play an MP3 in AVQueuePlayer.
- Set the time domain algorithm at a speed > 1.0x
- With an audio tap applied, but it doesn't have to do anything but return the same samples it's given.
- On device, with wired headphones connected.
- Listen to the audio on the headphones.

You may need to try these steps a few times for the repro.. I'm usually able to see one reproduction of the bug for every 5→10 minutes of testing. If it's not happening, try restarting the app.
1. Play the audio for a few minutes
2. Skip back 30s.
3. Repeat

Expected Results:
Audio should play continuously and skip back 30s action should skip back ~30s

Observed Results:
Audio occasionally jumps back 15-30s further than it should and plays silence until it catches up to the correct skip position.

Logs from attached example project when the bug happens, with notes in brackets
🕐 Current Position: 1413.004114134   <Playing normally>
🕐 Current Position: 1414.007139195
🕐 Current Position: 1415.004220812
🕐 Current Position: 1416.004286289
🕐 Current Position: 1417.004487639
🕐 Current Position: 1418.004845334
🕐 Current Position: 1419.004279152
🕐 Current Position: 1420.004413974
🕐 Current Position: 1421.026221867
🙋‍ Jump To Position: 1391.504362935   <Seek requested>
🕐 Current Position: 1421.512801041
🕐 Current Position: 1391.504362935   <Momentarily plays at the correct position>
🏀 Jumped To 1391.504362935
🕐 Current Position: 1374.64510314    <Now it has snapped back an additional 17s>
🕐 Current Position: 1374.646273389   <Silence playing>
🕐 Current Position: 1375.004520828
🕐 Current Position: 1376.00353113
🕐 Current Position: 1377.004114683
🕐 Current Position: 1378.004356974
🕐 Current Position: 1379.004073539
🕐 Current Position: 1380.003804354
🕐 Current Position: 1381.003753629
🕐 Current Position: 1382.003896308
🕐 Current Position: 1383.004547355
🕐 Current Position: 1384.004591256
🕐 Current Position: 1385.003892891
🕐 Current Position: 1386.004328898
🕐 Current Position: 1387.004366748
🕐 Current Position: 1388.003907351
🕐 Current Position: 1389.004090953
🕐 Current Position: 1390.004319441
🕐 Current Position: 1391.003856582   
🕐 Current Position: 1392.004097223  <Audio kicks in again as we reach the point we were supposed to be at>
🕐 Current Position: 1393.004452206

Version:
iOS 11 Beta 2

Notes:
We first noticed this bug after adding an audioTap to our app.

Note that all the steps above matter, including wired headphones — we weren't able to recreate it over other audio routes.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!