React-native-track-player: Background mode not working ?

Created on 25 Nov 2019  Â·  21Comments  Â·  Source: react-native-kit/react-native-track-player

Issue

I'm currently use react-native-track-player to stream audio from Internet. Works fine.

I would like now to use it in background mode, to be able to continue to listen to radio if my ap is in background mode.

I followed instructions from https://react-native-kit.github.io/react-native-track-player/background/, so add capabilities in xCode, with should be enough.

It doesn't work so I also add

TrackPlayer.updateOptions({
    stopWithApp: false
});

but stil not working.

Any idea or experience with this audio library in background mode ? Thanks !

Configuration

"react-native-track-player": "^1.1.8"

System:
OS: macOS 10.15.1
CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Memory: 1.45 GB / 24.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.1 - /usr/local/bin/node
npm: 6.13.1 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1

iOS

Most helpful comment

try selecting Background processing as well in Background modes:
Screen Shot 2019-12-08 at 8 33 27 PM

it worked for me.

All 21 comments

I'm also getting this issue in iOS release mode.
react-native: 0.61.4 => 0.61.4
"react-native-track-player": "^1.1.8"

Anyone an idea ?
The extension looses its usefulness if not being able to play in the background!
Is it working well for someone ?

try selecting Background processing as well in Background modes:
Screen Shot 2019-12-08 at 8 33 27 PM

it worked for me.

@mynameisguy I've been trying to make this fixes for a week now. What you mentioned didn't work for me.
Some more info from my specific case:

  • The app gets killed after ~50 sec on a physical device.
  • This issue only appears on iPhones older than iPhone 11 on iOS 13.x
  • App doesn't get killed if no audio is playing
  • The app kill gives no errors the only logs in XCode are:
2019-12-15 18:28:15.601456-0500 myapp[5125:748493] Can't end BackgroundTask: no background task exists with identifier 30 (0x1e), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
2019-12-15 18:28:35.321902-0500 myapp[5125:748493] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2019-12-15 18:28:35.322155-0500 myapp[5125:748493] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
Message from debugger: Terminated due to signal 9
  • Console give the following log before app gets killed:
default 18:36:46.629603 -0500   myapp   63.082s [C15] path:cancel
default 18:36:46.630648 -0500   myapp   boringssl_context_message_handler(2257) [C15.1:2][0x11309aa80] Writing SSL3_RT_ALERT 2 bytes
default 18:36:46.630734 -0500   myapp   boringssl_context_handle_warning_alert(1892) [C15.1:2][0x11309aa80] write alert, level: warning, description: close notify
default 18:36:46.630799 -0500   myapp   boringssl_session_disconnect(539) [C15.1:2][0x11309aa80] SSL_shutdown 0
default 18:36:46.630984 -0500   myapp   nw_protocol_tcp_log_summary [C15.1:3] 
    [A38B87E0-D739-47D5-8119-5548DCC9E6F2 192.168.1.110:52105<->172.217.1.10:443]
    Init: 1, Conn_Time: 19.184ms, Syn's: 1, WR_T: 0/0, RD_T: 0/0, TFO: 0/0/0, ECN: 0/0/0, TS: 1
    RTT_Cache: kernel, rtt_upd: 28, rtt: 41.406ms, rtt_var: 13.750ms rtt_nc: 41.406ms, rtt_var_nc: 13.750ms
default 18:36:46.631500 -0500   myapp   nw_flow_disconnected [C15.1 172.217.1.10:443 cancelled channel-flow ((null))] Output protocol disconnected
default 18:36:46.631878 -0500   myapp   nw_connection_report_state_with_handler_on_nw_queue [C15] reporting state cancelled
default 18:36:46.631943 -0500   myapp   removing all entries config 0x28215ef00
default 18:36:46.632431 -0500   myapp   tcp_output [C15.1:3] flags=[F.] seq=2057468148, ack=3596502254, win=1024 state=FIN_WAIT_1 rcv_nxt=3596502254, snd_una=2057468085
default 18:36:46.632816 -0500   myapp   nw_protocol_boringssl_remove_input_handler(1012) [C15.1:2][0x11309aa80] nw_protocol_boringssl_remove_input_handler forced true
default 18:36:46.633219 -0500   myapp   nw_protocol_boringssl_remove_input_handler(1030) [C15.1:2][0x11309aa80] Transferring nw_protocol_boringssl_t handle back into ARC for autorelease
default 18:36:46.663985 -0500   myapp   tcp_input [C15.1:3] flags=[F.] seq=3596502254, ack=2057468149, win=340 state=FIN_WAIT_1 rcv_nxt=3596502254, snd_una=2057468148
default 18:36:46.668160 -0500   symptomsd   defusing ticker tickerFatal having seen progress by flow for app.myapp.ent, rxbytes 24029 duration 63.111 seconds started at time: Sun Dec 15 18:35:43 2019
default 18:36:48.336714 -0500   backboardd  Connection removed: IOHIDEventSystemConnection uuid:F268F4B0-ECC4-4ED1-AB76-4D29E17B5139 pid:5137 process:myapp type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 380 attributes:{
    HighFrequency = 0;
    bundleID = "app.myapp.ent";
    pid = 5137;
} inactive:0 events:6 mask:0x800
default 18:36:48.337282 -0500   SpringBoard [application<app.myapp.ent>:5137] Now flagged as pending exit for reason: workspace client connection invalidated
default 18:36:48.337582 -0500   symptomsd   Received (FATAL) CPU usage trigger: 
  myapp[5137] (/private/var/containers/Bundle/Application/B7B387EA-B291-4F12-B0EA-DBAA15FACF54/myapp.app/myapp) used 48.00s of CPU over 53.37 seconds (averaging 89%), violating a CPU usage limit of 48.00s over 60 seconds.
default 18:36:48.338317 -0500   runningboardd   XPC connection invalidated: [application<app.myapp.ent>:5137]
default 18:36:48.338858 -0500   symptomsd   Fatal RESOURCE_NOTIFY trigger for myapp [5137] (48000199875 nanoseconds of CPU usage over 53.00s seconds, violating limit of 48000000000 nanoseconds of CPU usage over 60.00s seconds)
default 18:36:48.342608 -0500   mediaserverd    AudioSession_SubServer.cpp:107:ClientDied: { "action":"client_died", "session":{"ID":"0x1f5e5","PID":5137,"name":"myapp"}, "details":null }
default 18:36:48.344371 -0500   mediaremoted    Client <MRDMediaRemoteClient 0x10584ba30, bundleIdentifier = app.myapp.ent, pid = 5137> invalidated.
default 18:36:48.356408 -0500   mediaremoted    [ExternalDeviceServer] Removing television endpoint for client <MRDMediaRemoteClient 0x10584ba30, bundleIdentifier = app.myapp.ent, pid = 5137>
default 18:36:48.356459 -0500   mediaremoted    [MRDNowPlayingOriginClient] Removing nowPlayingClient <_MRNowPlayingClientProtobuf: 0x104f51140> {
    bundleIdentifier = "app.myapp.ent";
    displayName = myapp;
    processIdentifier = 5137;
    processUserIdentifier = 501;
} for origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.356489 -0500   mediaremoted    Set: origin-Rick’s Phone-1280262988/client--0/player-(null) setting inferredNowPlayingClient from <<_MRNowPlayingClientProtobuf: 0x104f3f7d0> {
    bundleIdentifier = "app.myapp.ent";
    displayName = myapp;
    processIdentifier = 5137;
    processUserIdentifier = 501;
}> to <(null)>
default 18:36:48.356526 -0500   mediaremoted    [MRDNowPlayingOriginClient] ActiveNowPlayingClient changed from origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer to origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.360688 -0500   mediaremoted    Set: origin-Rick’s Phone-1280262988/client--0/player-(null) setting computedNowPlayingClient from <<_MRNowPlayingClientProtobuf: 0x104f3f7d0> {
    bundleIdentifier = "app.myapp.ent";
    displayName = myapp;
    processIdentifier = 5137;
    processUserIdentifier = 501;
}> to <(null)>
default 18:36:48.360724 -0500   mediaremoted    Removing client <MRDMediaRemoteClient 0x10584ba30, bundleIdentifier = app.myapp.ent, pid = 5137>
default 18:36:48.361188 -0500   nanomediaremotelinkagent    Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.430419 -0500   CarPlay Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.431121 -0500   mDNSResponder   [R45583] DNSServiceCreateConnection STOP PID[5137](myapp)
default 18:36:48.431234 -0500   runningboardd   [application<app.myapp.ent>:5137] Death sentinel fired!
default 18:36:48.432035 -0500   corespeechd Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.448753 -0500   mediaserverd    Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.481703 -0500   callservicesd   Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.482571 -0500   contextstored   Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.483367 -0500   suggestd    Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.483612 -0500   wifid   Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.484102 -0500   homed   Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.484283 -0500   duetexpertd Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.484514 -0500   BTAvrcp Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.484798 -0500   assistantd  Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.485083 -0500   watchlistd  Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.486409 -0500   SpringBoard Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.503307 -0500   mediaremoted    Setting cached activePlayerPath origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer -> origin-Rick’s Phone-1280262988/client--0/player-(null)
default 18:36:48.519883 -0500   mediaremoted    Posting com.apple.MediaRemote.activePlayerPathDidChange because activePlayerPath changed from <origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137/player-MediaRemote-DefaultPlayer> to <(null)>
default 18:36:48.522319 -0500   nanomediaremotelinkagent    Request: supportedCommands<CD7AC8DF-E6FF-4D2F-8F26-0D6865CE3EA8> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.522424 -0500   nanomediaremotelinkagent    Response: supportedCommands<CD7AC8DF-E6FF-4D2F-8F26-0D6865CE3EA8> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.0018 seconds
default 18:36:48.525155 -0500   CarPlay Request: supportedCommands<69981A22-1C86-42B0-BFED-02DD7D12C248> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.529094 -0500   BTAvrcp Request: supportedCommands<4D13FB97-F210-44BF-881A-80AF93208F49> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.529229 -0500   mediaserverd    Request: supportedCommands<DE4C1705-91B8-4C24-B0F3-62DE70515849> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.529800 -0500   callservicesd   Request: supportedCommands<F4AAFE8B-A43A-41F0-9754-2768BD2E1229> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.538106 -0500   mediaserverd    -CMSessionManager_NowPlaying- CMSMNP_UpdateNowPlayingApp: CMSession: Now Playing App is - app.myapp.ent and its state is - Stopped
default 18:36:48.543693 -0500   corespeechd Request: supportedCommands<BE98EC17-051D-465B-8B32-CD8CADC21E08> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.544159 -0500   duetexpertd Request: supportedCommands<04F69A21-EC63-4936-AC10-715830977296> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.544501 -0500   wifid   Request: supportedCommands<25657D5D-89F0-4CB2-A471-D20007793450> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.545925 -0500   assistantd  Request: supportedCommands<363FB1E4-54BE-493D-B142-2F7AAC918C58> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.550429 -0500   SpringBoard Request: supportedCommands<7815FDFB-CEB0-41B6-8720-F76037F44BF8> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.551011 -0500   SpringBoard application<app.myapp.ent> now playing with audio: NO
default 18:36:48.551682 -0500   runningboardd   Invalidating assertion 26-448-46341 (target:application<app.myapp.ent>) from originator 448
default 18:36:48.552009 -0500   mediaserverd    MEDeviceStreamClient.cpp:430:RemoveRunningClient: AQME device AQDefaultDevice: client stopping: <AudioQueueObject@0x101c7ac00; Unknown FigPlayer; sid:0x1f5e5, myapp(5137), 'prim'; play>; running count now 0
default 18:36:48.557479 -0500   mediaserverd    AudioSessionServerImp.cpp:4319:AudioSessionDestroySessionForPID: { "action":"destroy_session", "session":{"ID":"0x1f5e8","PID":5137,"name":"myapp","type":"Fig"}, "details":null }
default 18:36:48.557503 -0500   mediaserverd    -CMSessionMgr- cmsSetIsPlaying: CMSession: 'sid:0x1f5e5, myapp(5137), 'prim'' with [MediaPlayback/Default] [NonMixable] [System Music] stopping playing. Ringer switch state: OFF. Silent muted: false.
default 18:36:48.557538 -0500   mediaserverd    CAReportingClient.mm:470:-[CAReportingClient sendMessage:category:type:reporters:]: message {
    MXSessionVolume = "0.625";
    MXSessionVolumeCategory = "Audio/Video";
    MXSessionVolumeOperationProcess = "app.myapp.ent";
    MXSessionVolumeOperationTime = 99495;
    MXSessionVolumePlayingState = 0;
}: (
    124554051654
)
default 18:36:48.557712 -0500   mediaserverd    -CMSessionMgr- cmsSetIsActive: CMSession: 'sid:0x1f5e5, myapp(5137), 'prim'' with [MediaPlayback/Default] [NonMixable] [System Music] siriEndpointID: (null) going inactive 0 1
default 18:36:48.557793 -0500   mediaserverd    CAReportingClient.mm:470:-[CAReportingClient sendMessage:category:type:reporters:]: message {
    MXSessionVolume = "0.625";
    MXSessionVolumeOperationProcess = "app.myapp.ent";
    MXSessionVolumeOperationTime = 99495;
    MXSessionVolumePlayingState = 0;
}: (
    124554051654
)
default 18:36:48.557967 -0500   mediaserverd    -CMSUtilities- CMSUtility_SendSessionStateAndVolumeReportToAudioToolBox: CMSession: Stopping reporter for session : sid:0x1f5e5, myapp(5137), 'prim', reporter id = 124554051654
default 18:36:48.558260 -0500   powerd  Process mediaserverd.29 Released NoIdleSleepAssertion "MediaExperience.sid:0x1f5e5, myapp(5137), 'prim'(app.myapp.ent).isplaying" age:00:00:53  id:4295006231 [System: PrevIdle SysAct]
default 18:36:48.565258 -0500   runningboardd   Invalidating assertion 26-29-46338 (target:application<app.myapp.ent>) from originator 29
default 18:36:48.569353 -0500   watchlistd  Request: supportedCommands<64F1D41C-4CFF-43A5-95A4-C2F8AFF36467> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.572736 -0500   contextstored   Request: supportedCommands<38192DB8-B08C-48E0-8094-BABA8A6F24B3> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.573133 -0500   homed   Request: supportedCommands<D77AD539-894E-4D4F-8E80-40BB9EB74B40> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-(null)
default 18:36:48.573710 -0500   CarPlay Response: supportedCommands<69981A22-1C86-42B0-BFED-02DD7D12C248> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.0486 seconds
default 18:36:48.593745 -0500   runningboardd   Removing process: [application<app.myapp.ent>:5137]
error   18:36:48.593871 -0500   runningboardd   RBSStateCapture remove item called for untracked item <RBProcessMonitorObserver: 0x102720d70; <RBProcess: 0x1024c90b0; 5137; identity: application<app.myapp.ent>>; configCount: 0>
default 18:36:48.593990 -0500   runningboardd   [application<app.myapp.ent>:5137] Deleting job: UIKitApplication:app.myapp.ent[fca3][rb-legacy]
default 18:36:48.594033 -0500   runningboardd   Removing job: <RBLaunchdJob: 0x1024cd140; pid=5137 UIKitApplication:app.myapp.ent[fca3][rb-legacy]>
default 18:36:48.594067 -0500   runningboardd   Removed job with label: UIKitApplication:app.myapp.ent[fca3][rb-legacy]
default 18:36:48.594109 -0500   runningboardd   Removing assertions for terminated process: [application<app.myapp.ent>:5137]
default 18:36:48.594164 -0500   runningboardd   Removed last relative-start-date-defining assertion for process application<app.myapp.ent>
default 18:36:48.595056 -0500   runningboardd   Calculated state for application<app.myapp.ent>: none (role: None)
default 18:36:48.595658 -0500   SpringBoard [application<app.myapp.ent>:5137]* Setting process debug state to: NO
default 18:36:48.595710 -0500   SpringBoard Application process state changed for app.myapp.ent: <SBApplicationProcessState: 0x2823c4180; pid: 5137; taskState: Running; visibility: Background>
default 18:36:48.623411 -0500   BTAvrcp Response: supportedCommands<4D13FB97-F210-44BF-881A-80AF93208F49> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1758 seconds
default 18:36:48.623715 -0500   contextstored   Response: supportedCommands<38192DB8-B08C-48E0-8094-BABA8A6F24B3> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1765 seconds
default 18:36:48.629623 -0500   corespeechd Response: supportedCommands<BE98EC17-051D-465B-8B32-CD8CADC21E08> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1818 seconds
default 18:36:48.629656 -0500   duetexpertd Response: supportedCommands<04F69A21-EC63-4936-AC10-715830977296> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1825 seconds
default 18:36:48.629999 -0500   wifid   Response: supportedCommands<25657D5D-89F0-4CB2-A471-D20007793450> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1852 seconds
default 18:36:48.633523 -0500   homed   Response: supportedCommands<D77AD539-894E-4D4F-8E80-40BB9EB74B40> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1808 seconds
default 18:36:48.646952 -0500   suggestd    Response: supportedCommands<EC3153E9-FE72-4315-A06D-B90213F5EF43> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1396 seconds
default 18:36:48.647153 -0500   SpringBoard Response: supportedCommands<7815FDFB-CEB0-41B6-8720-F76037F44BF8> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.2371 seconds
default 18:36:48.648485 -0500   watchlistd  Response: supportedCommands<64F1D41C-4CFF-43A5-95A4-C2F8AFF36467> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.2116 seconds
default 18:36:48.650359 -0500   watchlistd  WLDPlaybackNowPlayingObserver: Now playing app did change to '(null)' (playing: 0) from 'app.myapp.ent'
default 18:36:48.654581 -0500   mediaremoted    Response: supportedCommands<34507DF8-9945-49D4-8231-B2784401ABC0> returned <0 commands> for origin-Rick’s Phone-1280262988/client-app.myapp.ent-0 (myapp)/player-(null) in 0.1303 seconds
default 18:36:48.660249 -0500   watchlistd  WLDPlaybackNowPlayingObserver: Now playing app did change to '(null)' (playing: 0) from 'app.myapp.ent'
default 18:36:48.667270 -0500   mediaremoted    Added PlayerPathInvalidationHandler 0x1058633c0 for origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer
default 18:36:48.667549 -0500   mediaremoted    [MRDLockScreenController] Setting playerPath from origin-Rick’s Phone-1280262988/client-app.myapp.ent-5137 (myapp)/player-MediaRemote-DefaultPlayer to (null)
default 18:36:48.667643 -0500   mediaremoted    Cleared app.myapp.ent-5137 as possible now playing application.
default 18:36:48.671670 -0500   watchlistd  WLDPlaybackManager: enqueue for dsid <WLKPlaybackSummary: 0x102969670> {
    bundleID = "app.myapp.ent";
    channelID = "<null>";
    completionState = "In Progress";
    contentID = "85A4A50E-2F54-4A2E-BFA1-1EC5940F6910";
    currentPlaybackDate = "<null>";
    duration = "1322.388";
    elapsedTime = "62.95176589488983";
    isAlwaysLive = 0;
    isTimerDerived = 0;
    playbackRate = 0;
    playbackState = Stopped;
    playbackType = VOD;
    serviceID = "<null>";
    timestamp = "2019-12-15 23:36:48 +0000";
}: 1090826225
default 18:36:48.685986 -0500   watchlistd  WLDPlaybackManager: No channel associated with bundle ID: app.myapp.ent. Ignoring report
error   18:36:48.699616 -0500   runningboardd   RBSStateCapture remove item called for untracked item 26-448-46341 (target:application<app.myapp.ent>)
error   18:36:48.699668 -0500   runningboardd   RBSStateCapture remove item called for untracked item 26-29-46338 (target:application<app.myapp.ent>)
default 18:36:48.759527 -0500   symptomsd   defusing ticker tickerFatal having seen progress by flow for app.myapp.ent, rxbytes 5476 duration 58.562 seconds started at time: Sun Dec 15 18:35:49 2019

It seems the app gets killed because it uses too much CPU in background?

Does IOS 13 need to add "Background Processing"?
It seems need to add "Permitted background task scheduler identifiers"
I'm confusing of the value in this.

This module does not work in background mode with iOS 13.
Is there any plan to update it ?
Or does anyone know another audio module that can work in background mode with iOS 13 ?

Any change on this? I'm dealing with the signal 9 crash as well.

This module works in background mode.
We use this module as a production music app.
If it doesn't work in the background, it could be another issue like memory leak.

@Saehanseul can you please confirm the versions which your using RN -v and trackplayer -v
This is happening for us after first song ends and after fetching song in the background, player goes to pause state and gets killed

Yep, this problem still exists. @curiousdustin do you have ideas about this problem?

You do not need the Background Processing mode to be enabled for this react-native-track-player.

I can also confirm that background playback does work in my production app in iOS 13.

For those experiencing the issue, are you able to reproduce the issue using the example app?

I experienced this error and it is not related to the library. Please check your app's performance thru xcode. In my case, I had a memory leak caused by useTrackPlayerProgress(500). After setting it to "1000", the error is gone.

Thanks! I haven't tried it yet but that very well may be my problem. What
caused the memory leak and why did this change fix it? Or does it just
delay the crash by slowing down but not preventing the memory leak?

On Fri, Jun 19, 2020 at 5:24 PM zeritte notifications@github.com wrote:

I experienced this error and it is not related to the library. Please
check your app's performance thru xcode. In my case, I had a memory leak
caused by using useTrackPlayerProgress(500). After setting it to "1000",
the error is gone.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/react-native-kit/react-native-track-player/issues/792#issuecomment-646865623,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAMJTRW6HBZO23BXXTKBGPDRXPJQXANCNFSM4JRHIRFA
.

It was working well on android but on iOS it was getting signal 9 error from xcode. The only reason was this hook and after editing it the error is gone. I update my screens by using position and duration values useTrackPlayerProgress hook provides. However, they (my screens) were getting updated unnecessarily when I go to background. So I implemented a simple logic:

const [appState, setAppState] = useState("active");
 useEffect(() => {
    AppState.addEventListener("change", appStateChange);
    return () => AppState.removeEventListener("change", appStateChange);
  }, []);

  const appStateChange = appState => {
    setAppState(appState);
  };

After getting app state information to state; I updated my component:
const { position, duration } = TrackPlayer.useTrackPlayerProgress(appState !== "active" ? 5000 : 500);
Meaning that it does not unnecessarily updates my component when app is in the background mode. Hope this helps!

I had the same problem of background audio not working and after hours I noticed that on the Setup initialization I had iosCategoryMode: "spokenAudio".
I corrected it deleting it and setting it to "default" and this solved my problem.
I'm writing this just to help if someone else has made the same mistake.

I had the same problem with iPhones older than iPhone 11. I think the reason is like said @FrankGoortani "It seems the app gets killed because it uses too much CPU in background".

I reproduce this bug with the example. I use an iphone 7 (physical device)

Any idea to fix this ?

@idir-s I not have this issue in my iphone7

I had all of that stuff added too and it wasn't working. All I had forgotten was
TrackPlayer.setupPlayer();
so make sure the track player is initialized (even if the audio is already working!) because my audio worked, just not in the background, even though I forgot to initialize the track player.

I am currently experiencing this problem. Does anyone have know a fix?

cc: @Begoodi @dcvz @timmywil @FrankGoortani

We've run into this same issue in our application. After some thorough debugging in XCode, we've found the issue to be messages being issued the native system from the useTrackPlayerProgress hook, as @zeritte mentioned above. The fix they suggested also works--making the sole parameter of the hook a number larger than the default of 1000. I used 50000 in my case, because the time to app crash turned out to be geometric to the increase in that value, i.e.: a value of 4000 crashed in the same amount (roughly) that the 1000 setting would, but 4800 would run for over 20 minutes before crashing, where 5000 seems to never crash. The value of 50000 should give us an interminal play period, and is probably overkill.

The root of this must be in the track player library. Aside from this duration parameter, there's nothing else exposed through the API which we could be misusing.

Below is the code I used for the fix. It is very similar to @zeritte's code:

  const [appState, setAppState] = useState('active')
  const appStateChange = appState => setAppState(appState)
  useEffect(() => {
    AppState.addEventListener('change', appStateChange)
    return () => AppState.removeEventListener('change', appStateChange)
  }, [])

  const { position, bufferedPosition } = useTrackPlayerProgress(
    appState === 'active' ? 1000 : 50000
  )

It is also worth noting that I found this impossible to duplicate on any iOS simulator target that I tried, both before and after the iOS 14.0 release that broke so many media-related things. I was also unable to reproduce it on an old iPad Mini 3 running iOS 12 that was tethered to my Mac via XCode.

We've run into this same issue in our application. After some thorough debugging in XCode, we've found the issue to be messages being issued the native system from the useTrackPlayerProgress hook, as @zeritte mentioned above. The fix they suggested also works--making the sole parameter of the hook a number larger than the default of 1000. I used 50000 in my case, because the time to app crash turned out to be geometric to the increase in that value, i.e.: a value of 4000 crashed in the same amount (roughly) that the 1000 setting would, but 4800 would run for over 20 minutes before crashing, where 5000 seems to never crash. The value of 50000 should give us an interminal play period, and is probably overkill.

The root of this must be in the track player library. Aside from this duration parameter, there's nothing else exposed through the API which we could be misusing.

Below is the code I used for the fix. It is very similar to @zeritte's code:

  const [appState, setAppState] = useState('active')
  const appStateChange = appState => setAppState(appState)
  useEffect(() => {
    AppState.addEventListener('change', appStateChange)
    return () => AppState.removeEventListener('change', appStateChange)
  }, [])

  const { position, bufferedPosition } = useTrackPlayerProgress(
    appState === 'active' ? 1000 : 50000
  )

It is also worth noting that I found this impossible to duplicate on any iOS simulator target that I tried, both before and after the iOS 14.0 release that broke so many media-related things. I was also unable to reproduce it on an old iPad Mini 3 running iOS 12 that was tethered to my Mac via XCode.

Had exact same issue and the above works like charm. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mckmarc picture mckmarc  Â·  4Comments

b3rkaydem1r picture b3rkaydem1r  Â·  3Comments

moduval picture moduval  Â·  4Comments

mnlbox picture mnlbox  Â·  4Comments

moduval picture moduval  Â·  4Comments