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

Fix lock screen dismiss animation not working on certain older systems #1550

Merged
merged 11 commits into from Mar 16, 2020

Conversation

joeljfischer
Copy link
Contributor

@joeljfischer joeljfischer commented Feb 7, 2020

Fixes #1504, #1565

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

  • I have verified that I have not introduced new warnings in this PR (or explain why below)
  • I have run the unit tests with this PR
  • I have tested this PR against Core and verified behavior (if applicable, if not applicable, explain why below).

Unit Tests

Unit tests currently do not exist for the SDLLockScreenPresenter class, so no new unit tests were added in this bugfix PR. They were run and pass.

Core Tests

  • Connected while DD_OFF.
  • Repeatedly enable / disable DD as fast as possible.
  • Connected, backgrounded app, disconnected, reconnected, foregrounded app

Core version / branch / commit hash / module tested against: Sync Gen 3.0 (19205_DEVTEST), Sync Gen 3.0 (17276_DEVTEST)
HMI name / version / branch / commit hash / module tested against: Same as above

Summary

  • This PR tracks dismissals to prevent "double" dismissals causing the dismiss animation to break.
  • Changes the synchronization of the lock manager to not run a bunch of code async.
  • Changes the startup sequence to account for cases where the app is backgrounded when starting.

Changelog

Bug Fixes
  • The lock screen dismiss animation will no longer break on older SDL systems.
  • Disconnecting and reconnecting an app in the background will no longer prevent the lock screen from being dismissed in certain cases.

CLA

@joeljfischer joeljfischer added bug A defect in the library manager-lockscreen Relating to the manager layer - lockscreen labels Feb 7, 2020
@joeljfischer joeljfischer self-assigned this Feb 7, 2020
@NicoleYarroch NicoleYarroch added this to In progress in v6.6.0 via automation Feb 10, 2020
Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found an issue.

SmartDeviceLink/SDLLockScreenPresenter.m Show resolved Hide resolved
v6.6.0 automation moved this from In progress to Waiting for Review Feb 20, 2020
* Check that the lock screen is presented before attempting the dismissal
* Fix `isPresentedOrPresenting` needs to be called on the main thread
* Change `dispatch_async`s in lock screen classes to run sync
* Check whether we actually dismissed a VC to ensure that when we stop the presenter, it doesn't clear the presented window or view controller
* When starting the lock manager, check if we're in the background and abort if we are. If we aren't, check if we didn't erase the lock view controller (and by extension, the window), which means that we may still need to dismiss it, then clear the presenter and re-setup
@NicoleYarroch
Copy link
Contributor

I got a crash when testing LMP with this branch installed to SYNC 3.0:

  1. Open LMP on the device and keep in the foreground.
  2. Set the SYNC 3.0 module to "parked".
  3. Connect the device to SYNC 3.0 using a USB cord. Launch the SDL app. The lock screen shows and dismisses.
  4. Trigger a DD_ON notification by setting the module to "moving".
  5. Put app on device in background.
  6. Pull USB cord. Device app should still be in background.
  7. Bring app on device to foreground

Expected Result

Lock screen dismisses

Actual Result

Lock screen dismisses and app crashes.

2020-02-25 11:23:52.832912-0500 Livio Music[500:63894] [Lockscreen] Dismissing the lockscreen window
2020-02-25 11:23:52.835041-0500 Livio Music[500:63894] [Lockscreen] Presenting the lockscreen window
2020-02-25 11:23:53.394217-0500 Livio Music[500:63894] [Lockscreen] Lockscreen window dismissed
2020-02-25 11:23:53.396489-0500 Livio Music[500:63894] [Lockscreen] Presenting the lockscreen window
2020-02-25 11:23:53.402151-0500 Livio Music[500:63333] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <SDLLockScreenRootViewController: 0x103c15340>.'
*** First throw call stack:
(0x1884ed54c 0x1882080c8 0x18bf39e08 0x18bf3c148 0x18bf3c6f4 0x18bf556bc 0x18bf51c98 0x18bf519b0 0x18c9b4108 0x18c9b3dac 0x18c9eae0c 0x18c9be088 0x18c9be5b0 0x18c9be708 0x18efb2038 0x1037ff32c 0x10380d3e0 0x188468700 0x18846345c 0x188462978 0x192592534 0x18c554f0c 0x10053d184 0x1882e2f04)
libc++abi.dylib: terminating with uncaught exception of type NSException

Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment about the library crashing.

* updateLockScreenToShow now has a completion handler to allow the startup to ensure that it's finished dismissing or presenting before re-setting up the lock screen
@joeljfischer
Copy link
Contributor Author

@NicoleYarroch I believe I have fixed the issue.

Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

SmartDeviceLink/SDLLockScreenPresenter.m Show resolved Hide resolved
SmartDeviceLink/SDLLockScreenPresenter.m Outdated Show resolved Hide resolved
Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lock screen does not show if you follow these steps with iPhone 11 (iOS 13.3.1) and SYNC v3.0:

  1. Set head unit moving status to "parked".
  2. Connect device to head unit with a USB cord and launch SDL app by tapping on the SDL app icon on the head unit.
  3. Open the app on the device.
  4. Toggle the driver distraction status by setting the moving status to "speed".
  5. Put app on the device in the background. App should not be killed.
  6. Disconnect USB cord. App should not be killed.
  7. Connect USB cord.
  8. Open the app on the device.

Expected Result

Lock screen should show since the head unit moving status is still set to "speed".

Actual Result

Lock screen is dismissed.

SmartDeviceLink/SDLLockScreenPresenter.m Outdated Show resolved Hide resolved
* Fix the lock screen not showing if the app is started, DD is on, the app is put into the background on the phone, then the app is disconnected, reconnected, then put into the foreground on the phone.
* Stopping the LSM presenter now takes a completion handler
* Starting the LSM now checks the presenter immediately to see if the lock screen should be presented
Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug 1

The locks screen is still presented when these steps are followed:

  1. App on device is closed.
  2. Connect app to TDK that is set to "Parked". Launch SDL app on HMI if necessary.
  3. Open app on device.
  4. Toggle the TDK's moving status to "Speed".
  5. Put app on device in background.
  6. Pull USB cord.
  7. Bring app on device back to foreground

Expected Result

Lock screen does not show because the device is not connected to the TDK

Actual Resul

Lock screen dismisses but then shows again.

Bug 2

The lock screen is not presented when these steps are followed:

  1. Open app on device. Put app on device in background.
  2. Connect app to TDK that is set to "Speed". Launch SDL app on HMI if necessary.
  3. Bring app on device to foreground.

Expected Result

Lock screen shows because the TDK moving status is set to "speed"

Actual Resul

Lock screen does not show.

@joeljfischer
Copy link
Contributor Author

@NicoleYarroch Bug 1 is fixed, Bug 2 I only saw once out of 8 tries and have not been able to replicate it since.

* Clear the last lock notification to ensure that the lock screen is not presented when not connected
@NicoleYarroch NicoleYarroch self-requested a review March 12, 2020 14:46
Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found an issue where the lockscreen never presents.

SmartDeviceLink/SDLLockScreenManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLLockScreenManager.m Outdated Show resolved Hide resolved
SmartDeviceLink/SDLLockScreenManager.m Show resolved Hide resolved
SmartDeviceLink/SDLLockScreenPresenter.m Outdated Show resolved Hide resolved
// Store the expected state of the lockscreen
self.shouldShowLockScreen = show;

if (show) {
[self sdl_presentWithCompletionHandler:^{
if (self.shouldShowLockScreen) { return; }
if (self.shouldShowLockScreen) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use weakSelf/strongSelf in this block

self.lockWindow = nil;
[self sdl_dismissWithCompletionHandler:^(BOOL success) {
if (success) {
self.lockWindow = nil;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use weakSelf

SmartDeviceLink/SDLLockScreenPresenter.m Outdated Show resolved Hide resolved
* Make sure `stop` completion handler is always called
* Use strong / weak in all blocks
v6.6.0 automation moved this from Waiting for Review to Reviewer approved Mar 16, 2020
Copy link
Contributor

@NicoleYarroch NicoleYarroch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smoke tested with both template app (iOS 13, 12, and 11) and with streaming video/audio app (iOS 13, 12, and 11)

@joeljfischer joeljfischer merged commit 1699ef8 into develop Mar 16, 2020
v6.6.0 automation moved this from Reviewer approved to Done Mar 16, 2020
@joeljfischer joeljfischer deleted the bugfix/issue-1504-lock-screen-dismiss-animation branch March 16, 2020 15:58
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 manager-lockscreen Relating to the manager layer - lockscreen
Projects
No open projects
v6.6.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants