Commit e7d6b922 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Start broadcasting when BVC's view is visible.

BVC previously used self.visible, which is set in |-viewWillAppear:|, as
a trigger to start broadcasting its UI state.  However, cancelled
UIViewController transitions can sometimes result in |-viewWillAppear:|
being called without its accompanying |-viewDidAppear:| and
|-viewWillDisappear:| selectors.  As a result, BVC continued to
broadcast its UI even if its views were removed from the hierarchy and
deallocated, thus resulting in the crash from crbug.com/915123.

This CL updates BVC.broadcasting to be gated on BVC.viewVisible, which
is instead set in |-viewDidAppear:| after a successful presentation.
In addition to mitigating the crash, this also is an improvement
semantically, as BVC should not be broadcasting its state until it is
fully presented.  If objects care about BVC's UI during a transition,
it should be using the transition coordinator.

Currently, the BVC's broadcasted values are only used by
FullscreenController, and no scrolling is occurring in between
|-viewWillAppear:| and |-viewDidAppear:|, meaning that this CL has
no functional change.

Bug: 915123, 916581
Change-Id: Ifc0245e6e93f823c733be41ea471954912e7b577
Reviewed-on: https://chromium-review.googlesource.com/c/1388713Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618654}
parent d51fd53d
...@@ -937,7 +937,6 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -937,7 +937,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
return; return;
_visible = visible; _visible = visible;
[self updateBroadcastState];
} }
- (void)setViewVisible:(BOOL)viewVisible { - (void)setViewVisible:(BOOL)viewVisible {
...@@ -946,6 +945,7 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -946,6 +945,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
_viewVisible = viewVisible; _viewVisible = viewVisible;
self.visible = viewVisible; self.visible = viewVisible;
[self updateDialogPresenterActiveState]; [self updateDialogPresenterActiveState];
[self updateBroadcastState];
} }
- (void)setBroadcasting:(BOOL)broadcasting { - (void)setBroadcasting:(BOOL)broadcasting {
...@@ -2467,7 +2467,7 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2467,7 +2467,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
} }
- (void)updateBroadcastState { - (void)updateBroadcastState {
self.broadcasting = self.active && self.visible; self.broadcasting = self.active && self.viewVisible;
} }
- (void)updateDialogPresenterActiveState { - (void)updateDialogPresenterActiveState {
......
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