Bug 237799

Summary: Unable to resume HLS stream in Safari after backgrounding the app
Product: WebKit Reporter: Davis Gossage <davis>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: adam, davis, jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: iPhone / iPad   
OS: iOS 15   
Attachments:
Description Flags
WebKit.GPU process logs
none
simulator sysdiagnose
none
video of issue none

Description Davis Gossage 2022-03-11 15:51:46 PST
Created attachment 454520 [details]
WebKit.GPU process logs

I'm not able to resume an HLS stream in mobile Safari after backgrounding the app
Issue is 100% reproducible on Simulator running iOS 13.4 RC. It also reproduces on my iPhone 12 running iOS 13.4 RC

Issue occurred at 15:35:39

Steps to reproduce
- Open https://codepen.io/dgoss/full/eYyOXJX in mobile Safari
- Play 10 seconds of the HLS stream, pause
- Background the app for 10 seconds
- Open mobile Safari, tap Play

WebKit logs that seem relevant

App enters background, WebKit tells MediaPlayer to purge resources
default	15:35:13.302978-0800	71785	com.apple.WebKit.GPU	MediaPlayerPrivateAVFoundationObjC::setBufferingPolicy(4B3AC1364A25C7FC) PurgeResources
default	15:35:13.303014-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfsi_performCurrentResourceConservationAction: [0x125d07280|P/MV] Setting resourceConservationLevelWhenPaused to 3

CoreMedia deletes some tracks
default	15:35:13.306446-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_DeleteTrack: <0x126040a00|I/TKA.01> (0) track 3
default	15:35:13.306461-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_StopFeedingTrack: track 3 stopped feeding without setting EndTimer
default	15:35:13.306510-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_DeleteTrack: <0x126040a00|I/TKA.01> (0) track 5
default	15:35:13.306575-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_StopFeedingTrack: track 5 stopped feeding without setting EndTimer

More purging
default	15:35:16.594082-0800	71785	com.apple.WebKit.GPU	0x104fe3430 - GPUProcess::prepareToSuspend(), isSuspensionImminent: 0
default	15:35:38.120907-0800	71785	com.apple.WebKit.GPU	MediaPlayerPrivateAVFoundationObjC::setBufferingPolicy(4B3AC1364A25C7FC) MakeResourcesPurgeable

App enters foreground and FigStreamPlayer is not ready to play, FigStreamPlayer never recovers
default	15:35:39.340332-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_CheckIfLikelyToKeepUpAndNotify: tried to force playback but NOT ready for playback (0 buffered)
default	15:35:39.340410-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_PostNotificationFromDispatch: posting Remote_RateWillChangeTo on 0x125d07280 (0x6000027d5340)
default	15:35:39.340435-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_PostNotificationFromDispatch: posting RateDidChange on 0x125d07280 (0x6000027d5100)
default	15:35:39.340451-0800	71785	com.apple.WebKit.GPU	<<<< FigStreamPlayer >>>> fpfs_PostNotificationFromDispatch: posting PlaybackStateDidChange on 0x125d07280 (0x6000027d5020)
Comment 1 Davis Gossage 2022-03-11 15:53:18 PST
Created attachment 454521 [details]
simulator sysdiagnose
Comment 2 Davis Gossage 2022-03-11 15:54:45 PST
Created attachment 454522 [details]
video of issue
Comment 3 Davis Gossage 2022-03-11 15:57:04 PST
Also filed feedback https://feedbackassistant.apple.com/feedback/9954511
Comment 4 Alexey Proskuryakov 2022-03-11 16:40:01 PST
rdar://90184838
Comment 5 Alexey Proskuryakov 2022-03-11 16:42:01 PST
The content of attachment 454521 [details] has been deleted for the following reason:

Let's not keep the sysdiagnose here, it's sufficient to have internally at Apple.