Commit 3fb3face authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Mitigate white screen while uploading crash reports.

Between when the root view controller is created and the new (or active)
tab is displayed, there is a brief interval when the root view controller
is displayed. This is usually less than one display refresh cycle, but
if (for example) a crash is being uploaded on a slow device, it may
be longer than that. If so, a white screen will appear (this is the root
view controller's view when it doesn't contain a tab switcher).

To mitigate this effect, this CL has the main view controller add a copy
of the launch screen view to its view hierarchy. It is removed as soon as
another view controller is added as a child of the main view controller.

This is the same approach that's used to solve a similar issue when showing
the FRE on some devices. It's terrible and we will find something better
soon, but this will resolve the issue for M65.

Bug: 803758
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ife105aa253019b41eac5002a33e69da71eb51944
Reviewed-on: https://chromium-review.googlesource.com/920521
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537438}
parent c09049ec
......@@ -21,6 +21,7 @@ source_set("main") {
deps = [
":feature_flags",
"//base",
"//ios/chrome/app/resources:launchscreen_xib",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browsing_data",
......
......@@ -5,6 +5,8 @@
#import "ios/chrome/browser/ui/main/main_presenting_view_controller.h"
#import "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/main/transitions/bvc_container_to_tab_switcher_animator.h"
#import "ios/chrome/browser/ui/main/transitions/tab_switcher_to_bvc_container_animator.h"
......@@ -19,6 +21,9 @@
@property(nonatomic, strong) BVCContainerViewController* bvcContainer;
// A copy of the launch screen view used to mask flicker at startup.
@property(nonatomic, strong) UIView* launchScreen;
// Redeclared as readwrite.
@property(nonatomic, readwrite, weak) id<TabSwitcher> tabSwitcher;
......@@ -28,10 +33,24 @@
@synthesize animationsDisabledForTesting = _animationsDisabledForTesting;
@synthesize tabSwitcher = _tabSwitcher;
@synthesize bvcContainer = _bvcContainer;
@synthesize launchScreen = _launchScreen;
- (void)viewDidLoad {
// Set a white background color to avoid flickers of black during startup.
self.view.backgroundColor = [UIColor whiteColor];
// In some circumstances (such as when uploading a crash report), there may
// be no other view controller visible for a few seconds. To prevent a
// white screen from appearing in that case, the startup view is added to
// the view hierarchy until another view controller is added.
NSBundle* mainBundle = base::mac::FrameworkBundle();
NSArray* topObjects =
[mainBundle loadNibNamed:@"LaunchScreen" owner:self options:nil];
UIViewController* launchScreenController =
base::mac::ObjCCastStrict<UIViewController>([topObjects lastObject]);
self.launchScreen = launchScreenController.view;
self.launchScreen.userInteractionEnabled = NO;
self.launchScreen.frame = self.view.bounds;
[self.view addSubview:self.launchScreen];
}
- (UIViewController*)activeViewController {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment