homerours / cordova-music-controls-plugin

A Cordova plugin displaying music controls in notifications (cordova-plugin-music-controls)
MIT License
155 stars 190 forks source link

Plugin crashes on iOS 13 #157

Open yoojene opened 5 years ago

yoojene commented 5 years ago

After upgrading to iOS 13, the plugin crashes the app as soon as the MusicControls.create({.. is called.

This happens on device and in the simulator


2019-08-27 11:55:58.144956+0100 App - Test[37550:871750] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c30bb6e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x000000010bc7bf57 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010c30b8e8 +[NSException raise:format:arguments:] + 88
    3   Foundation                          0x000000010adbac29 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
    4   MediaPlayer                         0x0000000109e77ad4 -[MPRemoteCommand addTarget:action:] + 1154
    5   Pfizeryanınızda - Test            0x0000000107ee5a0a -[MusicControls registerMusicControlsEventListener] + 394
    6   Pfizeryanınızda - Test            0x0000000107ee4087 -[MusicControls create:] + 407
    7   Pfizeryanınızda - Test            0x0000000107ff4f84 -[CDVCommandQueue execute:] + 900
    8   Pfizeryanınızda - Test            0x0000000107eb90ef -[CDVWKWebViewEngine handleCordovaMessage:] + 207
    9   Pfizeryanınızda - Test            0x0000000107eb8f6b -[CDVWKWebViewEngine userContentController:didReceiveScriptMessage:] + 187
    10  Pfizeryanınızda - Test            0x0000000107ebab3e -[CDVWKWeakScriptMessageHandler userContentController:didReceiveScriptMessage:] + 126
    11  WebKit                              0x000000010907f939 _ZN28ScriptMessageHandlerDelegate14didPostMessageERN6WebKit12WebPageProxyERKNS0_13FrameInfoDataERN7WebCore21SerializedScriptValueE + 217
    12  WebKit                              0x00000001091fa7a0 _ZN6WebKit29WebUserContentControllerProxy14didPostMessageERN3IPC10ConnectionEyRKNS_13FrameInfoDataEyRKNS1_13DataReferenceE + 168
    13  WebKit                              0x00000001093fc5fd _ZN3IPC13handleMessageIN8Messages29WebUserContentControllerProxy14DidPostMessageEN6WebKit29WebUserContentControllerProxyEMS5_FvRNS_10ConnectionEyRKNS4_13FrameInfoDataEyRKNS_13DataReferenceEEEEvS7_RNS_7DecoderEPT0_T1_ + 116
    14  WebKit                              0x0000000108f0fa3e _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 114
    15  WebKit                              0x000000010914506c _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 24
    16  WebKit                              0x0000000108efafd8 _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 108
    17  WebKit                              0x0000000108efdaee _ZN3IPC10Connection24dispatchIncomingMessagesEv + 586
    18  JavaScriptCore                      0x000000011dae29b4 _ZN3WTF7RunLoop11performWorkEv + 228
    19  JavaScriptCore                      0x000000011dae2c42 _ZN3WTF7RunLoop11performWorkEPv + 34
    20  CoreFoundation                      0x000000010c26f371 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    21  CoreFoundation                      0x000000010c26f301 __CFRunLoopDoSource0 + 81
    22  CoreFoundation                      0x000000010c26ead4 __CFRunLoopDoSources0 + 180
    23  CoreFoundation                      0x000000010c2697ef __CFRunLoopRun + 1263
    24  CoreFoundation                      0x000000010c268fd6 CFRunLoopRunSpecific + 438
    25  GraphicsServices                    0x00000001115c29f8 GSEventRunModal + 65
    26  UIKitCore                           0x000000011b9f4722 UIApplicationMain + 1621
    27  Pfizeryanınızda - Test            0x0000000107e6d141 main + 65
    28  libdyld.dylib                       0x000000010d6206ad start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
fdambrosio commented 5 years ago

this is very important!

NecroMan commented 5 years ago

Any news? Bug still present.

maunik318 commented 5 years ago

I'm also facing this issue. It's working on iOS 12.*

pedrofurtado commented 5 years ago

@homerours Any news? in iOS 13 does not work anymore :cry:

MarcelvanGastel commented 5 years ago

@homerours Any news? in iOS 13 does not work anymore 😢

https://github.com/homerours/cordova-music-controls-plugin/pull/158/files/90e3fe8838c3151bd8e51901079eb34740ec87c9

This fixed it for me

tbergeron commented 5 years ago

Does this plugin work for anyone AT ALL? I mean is it possible to have this fully working as intended? I've been using it for over a year on Android with no issues but never worked on iOS no matter the webview engine I use, etc...

jb280 commented 5 years ago

Does this plugin work for anyone AT ALL? I mean is it possible to have this fully working as intended? I've been using it for over a year on Android with no issues but never worked on iOS no matter the > webview engine I use, etc...

It has worked for me on both iOS and Android for over a year. The store/shipping builds still seem to work on iOS 13. However, I can't build a new working app with Xcode 11, or the Beta Xcode 13.2. I tried MarcelvanGastel's modifications twice, but that seems to cause build issues on my Ionic 3 app:

(node:22770) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'toLowerCase' of undefined

NecroMan commented 5 years ago

@homerours Any news? in iOS 13 does not work anymore 😢

https://github.com/homerours/cordova-music-controls-plugin/pull/158/files/90e3fe8838c3151bd8e51901079eb34740ec87c9

This fixed it for me

Still crash for me :(

yoojene commented 5 years ago

Made some updates to the PR, latest commits work for me - tested in iOS 13.1.2

jb280 commented 5 years ago

Made some updates to the PR, latest commits work for me - tested in iOS 13.1.2

I fixed my build issue. The audio does start playing..then I get: Playing stream with AVPlayer & default rate *** Assertion failure in -[MPSkipIntervalCommand addTarget:action:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/MediaPlayer/MobileMusicPlayer-4017.101.15/SDK/MPRemoteCommand.m:134

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.'

Did you modify other routines other than remoteEvent, playEvent, pauseEvent, nextTrackEvent prevTrackEvent returning MPRemoteCommandHandlerStatusSuccess?

Update I did get this to work if I comment out // hasSkipForward: true, // show skip forward button, optional, default: false // hasSkipBackward: true, // show skip backward button, optional, default: false This allows the audio to play, but I no longer have the skip buttons on the lock screen

I tried updating skipForwardEvent() and skipBackwardEvent() to be of type and return MPRemoteCommandHandlerStatus, but that didn't correct the exception if I set hasSkipForward /hasSkipForward to true

RomainDev25 commented 5 years ago

Hello this issue is fixed in this repo : https://github.com/ghenry22/cordova-music-controls-plugin

cordova plugin remove cordova-plugin-music-controls
cordova plugin add https://github.com/ghenry22/cordova-music-controls-plugin --save
jb280 commented 4 years ago

Hello this issue is fixed in this repo : https://github.com/ghenry22/cordova-music-controls-plugin

cordova plugin remove cordova-plugin-music-controls
cordova plugin add https://github.com/ghenry22/cordova-music-controls-plugin --save

Thank you!! This has the lock screen skip-controls enable now when I set them to be true! Everything seems to work in my app as before, as it did on the previous version of iOS!