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

Fixed the wrong window being shown by lock screen presenter #1503

Conversation

NicoleYarroch
Copy link
Contributor

@NicoleYarroch NicoleYarroch commented Dec 11, 2019

Fixes #1501

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 were run.

Core Tests

Smoke tests perform with SYNC 3.

Core version / branch / commit hash / module tested against: SYNC 3 v3.0
HMI name / version / branch / commit hash / module tested against: SYNC 3 v3.0

Summary

Fixed the lock screen presenter selecting the wrong UIWindow when the app has multiple UIWindows. This bug created the following issues:

  1. The wrong view controller snapshot was shown when presenting the lock screen window (snapshot is used for animating the presentation of the lock screen).
  2. The wrong UIWindow was made visible when dismissing the lock screen window.

Changelog

Bug Fixes
  • Fixed the lock screen presenter selecting the wrong UIWindow when the app has multiple UIWindows.

Tasks Remaining:

  • Smoke tests

CLA

@NicoleYarroch NicoleYarroch self-assigned this Dec 11, 2019
@NicoleYarroch NicoleYarroch added the bug A defect in the library label Dec 11, 2019
@NicoleYarroch NicoleYarroch changed the title Fixed the wrong window being shown by lock screen presenter WIP: Fixed the wrong window being shown by lock screen presenter Dec 11, 2019
Fixed black screen when lock screen is presented in background
@NicoleYarroch NicoleYarroch changed the title WIP: Fixed the wrong window being shown by lock screen presenter Fixed the wrong window being shown by lock screen presenter Dec 11, 2019
__weak typeof(self) weakself = self;
dispatch_async(dispatch_get_main_queue(), ^{
if (!([UIApplication sharedApplication].applicationState == UIApplicationStateActive)) {
// Don't present lock screen when app is backgrounded because the screenshot will be a black screen
Copy link
Contributor

Choose a reason for hiding this comment

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

What code causes this to work correctly when the app comes into the foreground?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code was removed


- (void)sdl_checkLockScreenStatus {
// Present the VC depending on the lock screen status
if (self.config.displayMode == SDLLockScreenConfigurationDisplayModeAlways) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation is 6 spaces. Do you have Xcode Preferences -> Text Editing -> Indentation, "Prefer Indent Using: Spaces" and "Tab Width / Indent Width" set to 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

NSArray<UIWindow *> *windows = appWindowScene.windows;
UIWindow *appWindow = nil;
for (UIWindow *window in windows) {
if (window != self.lockWindow) {
if (window.isKeyWindow) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will work for apps using iOS 13 scene API. keyWindow is deprecated, though this API appears not to be. In any case, I wouldn't trust it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code was removed

@@ -98,10 +99,11 @@ - (void)sdl_presentIOS13 {
}
}

// Find the currently visible app window
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Apparently in Xcode a tab = 4 spaces and in GitHub 6

@@ -169,7 +174,7 @@ - (void)sdl_dismissIOS12 {
UIWindow *appWindow = nil;
for (UIWindow *window in windows) {
SDLLogV(@"Checking window: %@", window);
if (window != self.lockWindow) {
if ([window.rootViewController isKindOfClass:[self.coveredRootViewController class]]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you directly check equality between window.rootViewController and coveredRootViewController? Imagine if the same class (or in the case of using isKindOfClass a subclass) is used in multiple windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code was removed

@@ -204,7 +209,7 @@ - (void)sdl_dismissIOS13 {
UIWindow *appWindow = nil;
for (UIWindow *window in windows) {
SDLLogV(@"Checking window: %@", window);
if (window != self.lockWindow) {
if ([window.rootViewController isKindOfClass:[self.coveredRootViewController class]]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code was removed

@NicoleYarroch
Copy link
Contributor Author

Closing in favor of #1509 as pretty much all the code was changed.

@joeljfischer joeljfischer deleted the bugfix/issue_1501_wrong_appwindow_shown_on_lockscreen_dismissal branch February 7, 2020 16:20
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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants