Bug 1215669 - Queue tab screenshots if BVC isn't visible #1206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think the issue here is that
WKWebView
doesn't render if its view controller isn't visible (presumably as an optimization). This fixes the problem by waiting until BVC is visible, then trying again.I spent awhile trying to figure out a good way to determine view controller visibility; in particular, I tried
self.navigationController?.visibleViewController === self
andisViewLoaded() && view.window != nil
. Those mostly work, but I found I could trigger some edge casey false positives if the screenshotting fires during the tab tray -> BVC transition (these conditions all returntrue
, yet the screenshot was still blank). I bit the bullet and tacked on aviewIsVisible
boolean that I just keep track of manually.