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

'SDLManagerDelegate`s are not called if the data session is established successfully but the lifecycle manager does not transition to state ready #1264

Closed
NicoleYarroch opened this issue May 16, 2019 · 3 comments
Assignees
Labels
bug A defect in the library
Projects
Milestone

Comments

@NicoleYarroch
Copy link
Contributor

NicoleYarroch commented May 16, 2019

Bug Report

The app's SDLManagerDelegates are not called if the data session is established successfully but the lifecycle manager never ends up in state SDLLifecycleStateReady.

This appears to be some sort of race condition in the lifecycle manager. The lifecycle manager was stuck in state SDLLifecycleStateSettingUpManagers so even though Core was sending notifications the app did not get the notifications because the lifecycle manager never finished setting up.

Reproduction Steps
  1. Race condition. I only had it happen once.
Expected Behavior

If the lifecycle manager errors out when setting up, the data session should be destroyed and re-created.

Observed Behavior

The data session stays open, but the app does not get notifications from Core. This means the SDL app UI is empty.

OS & Version Information
  • iOS Version: 12.1.4
  • SDL iOS Version: 6.2
  • Testing Against: SYNC 3.4
Test Case, Sample Code, and / or Example App

Swift example app in the SDL_iOS library

@NicoleYarroch NicoleYarroch added the bug A defect in the library label May 16, 2019
@NicoleYarroch NicoleYarroch added this to To do in v6.3 via automation May 16, 2019
@NicoleYarroch
Copy link
Contributor Author

I managed to recreate after pulling the USB cord rapidly multiple times. It looks like the the SDLFileManager never sends the ListFiles request for some reason.
Logs for Lifecycle Manager stuck in state `SDLLifecycleStateSettingUpManagers

@t-yoshii
Copy link

Hi @NicoleYarroch ,

I see the same issue in my environment. Here is my analysis.

SDLFileManager still attempts to resend file even after SDLLifecycleManager becomes Reconnecting and SDLFileManager becomes Shutdown. SDLFileManager enqueues a SDLUploadFileOperation to transactionQueue in sdl_uploadFile, but this operation is never finished because proxy is already dealloced and completionHandler is never executed.
Therefore, in next lifecycle, SDLListFilesOperation is never executed and SDLFileManager stays in FetchingInitialList.

I think that to check whether SDLFileManager is Ready state or not in sdl_canFileBeUploadedAgain will fix this issue.
https://github.com/smartdevicelink/sdl_ios/blob/master/SmartDeviceLink/SDLFileManager.m#L404

// io stream closed
11:54:18:970 🔵 DEBUG com.apple.root.default-qos.overcommit (SDL)Transport:SDLIAPDataSession:-[SDLIAPDataSession sdl_accessoryEventLoop]:337 - Closing the accessory event loop on thread: com.smartdevicelink.iostream
11:54:18:970 🔵 DEBUG com.apple.root.default-qos.overcommit (SDL)Transport:SDLIAPDataSession:-[SDLIAPDataSession sdl_closeSession]:352 - Closing EASession for accessory connection id: 35513592, name: SYNC 3
11:54:18:970 🔵 DEBUG com.apple.root.default-qos.overcommit (SDL)Transport:SDLIAPSession:-[SDLIAPSession stopStream:]:84 - Input stream closed
11:54:18:970 🔵 DEBUG com.apple.root.default-qos.overcommit (SDL)Transport:SDLIAPSession:-[SDLIAPSession stopStream:]:87 - Output stream closed
11:54:18:983 🔵 DEBUG com.apple.main-thread (SDL)Transport:SDLIAPDataSession:-[SDLIAPDataSession sdl_isIOThreadCanceled:completionHandler:]:137 - Stream thread canceled successfully
11:54:18:988 🔵 DEBUG com.sdl.rpcProcessingQueue (SDL)Lifecycle:SDLLifecycleManager:-[SDLLifecycleManager transportDidDisconnect]:705 - Transport Disconnected
// SDLLifecycleManager becomes `Reconnecting`.
11:54:18:988 ⚪ VERBOSE com.sdl.lifecycle (SDL)Utilities:SDLStateMachine:-[SDLStateMachine transitionToState:]:84 - State machine for class SDLLifecycleManager will transition from state Ready to state Reconnecting
11:54:18:988 ⚪ VERBOSE com.sdl.lifecycle (SDL)Lifecycle:SDLLifecycleManager:-[SDLLifecycleManager sdl_stopManager:]:240 - Stopping manager, will restart
11:54:18:988 ⚪ VERBOSE com.sdl.lifecycle (SDL)Transport:SDLIAPTransport:-[SDLIAPTransport sdl_stopEventListening]:126 - SDLIAPTransport stopped listening for events
11:54:18:989 🔵 DEBUG com.sdl.lifecycle (SDL)Transport:SDLIAPDataSession:-[SDLIAPDataSession destroySession]:124 - Destroying the data session
11:54:18:993 ⚪ VERBOSE com.apple.main-thread (SDL)Transport:SDLIAPDataSession:-[SDLIAPDataSession sdl_stop]:
// Proxy dealloc
11:54:18:996 ⚪ VERBOSE com.sdl.lifecycle (SDL)Proxy:SDLProxy:-[SDLProxy dealloc]:142 - Proxy dealloc

// SDLFileManager becomes `Shutdown`
11:54:18:997 ⚪ VERBOSE com.sdl.lifecycle (SDL)Utilities:SDLStateMachine:-[SDLStateMachine transitionToState:]:84 - State machine for class SDLFileManager will transition from state Ready to state Shutdown

// However, SDLFileManager still tries to upload file again.
11:54:19:005 🔵 DEBUG com.apple.main-thread (SDL)File:SDLFileManager:-[SDLFileManager sdl_uploadFile:completionHandler:]_block_invoke:405 - Attempting to resend file with name d7be4e1407fc0227 after a failed upload attempt

@NicoleYarroch
Copy link
Contributor Author

NicoleYarroch commented May 23, 2019

@t-yoshii Good catch. I created PR #1277 to fix this issue.

@NicoleYarroch NicoleYarroch added this to the 6.3.0 milestone May 23, 2019
v6.3 automation moved this from To do to Done May 28, 2019
@joeljfischer joeljfischer mentioned this issue Jun 24, 2019
1 task
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
  
Done
Development

No branches or pull requests

3 participants