Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAAccessoryManager#unregisterForLocalNotifications should not be called in SDLIAPTransport#dealloc #1329

Closed
t-yoshii opened this issue Jul 9, 2019 · 1 comment · Fixed by #1330
Assignees
Labels
bug A defect in the library
Projects

Comments

@t-yoshii
Copy link

t-yoshii commented Jul 9, 2019

Bug Report

When the delayed sdl_connect by old SDLIAPTransport instance is called after the reconnection by another SDLIAPTransport is done, deallc of old SDLIAPTransport occurs and causes unregistration of EAAccessoryManager. This prevents the succeeding EA events detection. Please check the following logs.

In addition, when other components other than SDL uses EA Accessory, EAAccessoryManager#unregisterForLocalNotifications also affects the EA event listening of such components.
One of our SDL apps uses EA accessory other than SDL. The application sometimes stops SDLManager (this lead to call EAAccessoryManager#unregisterForLocalNotifications) in some situation, but it still needs to use EA accessory for the other purpose (with other protocol strings.)

Therefore, in any way, I think SDL proxy framework should not call EAAccessoryManager#unregisterForLocalNotifications.

This is copied from the comment below.
#1315 (comment)

// Connect USB, iOS detects EAAccessoryArrived (USB) and EAAccessoryLeft (BT)
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(CoreAccessories)[691] <Notice>: accessoryd received EAAccessoryArrived <private>
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(CoreAccessories)[691] <Notice>: accessoryd received EAAccessoryLeft <private>, UUID <private>
 :
// EAAccessoryLeft event is processed
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:645 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPTransport:135 - Accessory with serial number: 1234567890, and connectionID: 37965985 disconnecting.
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:645 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:147 - Accessory (SABRE, 1234567890) disconnected during a data session
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:645 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:82 - SDLIAPTransport stopped listening for events
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:645 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:77 - Destroying the data session
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:668 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:339 - Closing the accessory event loop on thread: com.smartdevicelink.iostream
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:668 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:354 - Closing EASession for accessory connection id: 37965985, name: SABRE
 :
//
// EAAccessoryArrived event is processed
// Timer for `sdl_connect` is set.
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:678 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPTransport:102 - Accessory Connected (<EAAccessory: 0x2834803d0> { 
  connected:YES 
  connectionID:37965986 
  name: SABRE 
  manufacturer: Xevo 
  modelNumber: ToyotaCTS 
  serialNumber: 1234567890 
  ppid: (null) 
  firmwareRevisionActive: \134^A. 
  firmwareRevisionPending: (null) 
  hardwareRevision: \134^A. 
  dockType:  
  certSerial: 15 bytes 
  certData: 908 bytes 
  protocols: (
    "com.smartdevicelink.multisession",
    "com.xevokk-jtc.capp"
) 
  delegate: (null) 
}), Opening in 8.655s
 :
 :
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:684 \M-p\M^_\M^T\M-5 (SDL)Lifecycle:SDLLifecycleManager:720 - Transport Disconnected
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:684 \M-b\M^Z\M-* (SDL)Utilities:SDLStateMachine:84 - State machine for class SDLLifecycleManager will transition from state Ready to state Reconnecting
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:684 \M-b\M^Z\M-* (SDL)Lifecycle:SDLLifecycleManager:248 - Stopping manager, will restart
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:685 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:82 - SDLIAPTransport stopped listening for events
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:685 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:77 - Destroying the data session
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:698 \M-b\M^Z\M-* (SDL)Transport:SDLIAPDataSession:102 - Stopping data session but no thread established.
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:698 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPSession:84 - Attempting to close session with accessory: SABRE, but it is already closed
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:717 \M-b\M^Z\M-* (SDL)Proxy:SDLProxy:139 - Proxy dealloc
Jul  1 11:55:05 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:05:717 \M-b\M^Z\M-* (SDL)Utilities:SDLStateMachine:84 - State machine for class SDLFileManager will transition from state Ready to state Shutdown
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:450 \M-b\M^Z\M-* (SDL)Utilities:SDLStateMachine:84 - State machine for class SDLLifecycleManager will transition from state Reconnecting to state Started
 :
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:638 \M-p\M^_\M^T\M-5 (SDL)Lifecycle:SDLLifecycleManager:709 - Transport connected
Jul  1 11:55:06 iPhoneXS-M00326 assertiond[65] <Notice>: [CTSSimpleApp_ms:691] Deactivate assertion: <BKProcessAssertion: 0x1047240e0; "Shared Background Assertion 5 for UIEvolution.CTS-Simple-App" (finishTask:180s); id:\M-b\M^@\M-&8F7D536FC850>
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:638 \M-p\M^_\M^T\M-5 (SDL):SDLBackgroundTaskManager:57 - Ending background task with id: 17
Jul  1 11:55:06 iPhoneXS-M00326 assertiond[65] <Notice>: [CTSSimpleApp_ms:691] Setting jetsam priority to 3 [0x4]
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:638 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLSecondaryTransportManager:437 - Starting service 0xA on primary transport
Jul  1 11:55:06 iPhoneXS-M00326 assertiond[65] <Notice>: Updating PowerAssertion on CTSSimpleApp_ms:691
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:639 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLSecondaryTransportManager:437 - Starting service 0xB on primary transport
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:639 \M-b\M^Z\M-* (SDL)Utilities:SDLStateMachine:84 - State machine for class SDLSecondaryTransportManager will transition from state Started to state Configured
Jul  1 11:55:06 iPhoneXS-M00326 assertiond[65] <Notice>: [CTSSimpleApp_ms:691] Remove assertion: <BKProcessAssertion: 0x1047240e0; "Shared Background Assertion 5 for UIEvolution.CTS-Simple-App" (finishTask:180s); id:\M-b\M^@\M-&8F7D536FC850>
Jul  1 11:55:06 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:06:639 \M-b\M^Z\M-* (SDL)Utilities:SDLStateMachine:84 - State machine for class SDLLifecycleManager will transition from state Started to state Connected
 :
 :
// Timer for `sdl_connect` fired and this causes `SDLIAPTransport#dealloc` and EAAccessoryManager unregistration.
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:337 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:229 - Will not attempt to connect to an accessory because the data session disconnected. Waiting for lifecycle manager to create a new transport object.
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:337 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:517 - SDLIAPTransport dealloc
// This prevents succeeding EA event detection.
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:337 \M-b\M^Z\M-* (SDL)Transport:SDLIAPTransport:82 - SDLIAPTransport stopped listening for events
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:77 - Destroying the data session
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-b\M^Z\M-* (SDL)Transport:SDLIAPDataSession:102 - Stopping data session but no thread established.
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPSession:84 - Attempting to close session with accessory: SABRE, but it is already closed
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-b\M^Z\M-* (SDL)Transport:SDLIAPDataSession:373 - SDLIAPDataSession dealloc
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPDataSession:77 - Destroying the data session
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-b\M^Z\M-* (SDL)Transport:SDLIAPDataSession:102 - Stopping data session but no thread established.
Jul  1 11:55:14 iPhoneXS-M00326 CTSSimpleApp_ms(SmartDeviceLink)[691] <Notice>: 11:55:14:338 \M-p\M^_\M^T\M-5 (SDL)Transport:SDLIAPSession:84 - Attempting to close session with accessory: SABRE, but it is already closed
Reproduction Steps
  1. Connect SDL Proxy and SDL Core via Bluetooth
  2. Connect USB cable and switch the connection type to USB
  3. Disconnect USB cable switch the connection type to Bluetooth
  4. Repeat 1~3
Expected Behavior

Connection does not fail

Observed Behavior

Connection sometimes fails

OS & Version Information
  • iOS Version: iOS11, 12
  • SDL iOS Version: 6.3.0
  • Testing Against: Our internal devboard and OEM's HU.
Test Case, Sample Code, and / or Example App

I will create PR

@NicoleYarroch NicoleYarroch added the bug A defect in the library label Jul 9, 2019
@NicoleYarroch NicoleYarroch added this to To do in v6.4 via automation Jul 9, 2019
@NicoleYarroch NicoleYarroch removed this from To do in v6.4 Jul 9, 2019
@NicoleYarroch NicoleYarroch added this to To do in v6.3.1 via automation Jul 9, 2019
v6.3.1 automation moved this from To do to Done Jul 10, 2019
@theresalech
Copy link
Contributor

theresalech commented Jul 10, 2019

Fixed via #1336

@theresalech theresalech reopened this Jul 10, 2019
v6.3.1 automation moved this from Done to In progress Jul 10, 2019
v6.3.1 automation moved this from In progress to Done Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the library
Projects
No open projects
v6.3.1
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants