Skip to content

Instantly share code, notes, and snippets.

@sleroux
Created November 12, 2015 15:46
Show Gist options
  • Save sleroux/c2cef69ed0a57c89194f to your computer and use it in GitHub Desktop.
Save sleroux/c2cef69ed0a57c89194f to your computer and use it in GitHub Desktop.
BVC 2.0

Architecture Drawing - https://www.dropbox.com/s/xo8ra6gd1n687v7/IMG_0126.JPG?dl=0

WIP Branch - https://github.com/mozilla/firefox-ios/tree/sleroux/Bug1212021-InvertTabTray

Present Day BVC

(Potentially) Future BVC

  • Contains only one web view for the selected tab
    • Removes need for 'selectedTab' state
    • BVC can implicitly configure itself
    • We would pass in the Tab (currently named Browser) to the BVC when we instiatiate it
  • Is instantiated when tapping a tab from the Tab Tray and is deallocated when going back to the tray
  • WebViews are kept alive in the TabManager
  • One tab per BVC -> One HomeViewController per BVC
    • Would simplify/solve the state problem we have with Bookmarks

Questions:

  • What are the performance impliciations of moving from a singleton BVC model to per tab model?
  • Best way to manage getting this into mainline for 2.0 potentially?
  • Other ramifications?
    • I know theres already refactoring needed for handling the crash detection, queued tabs, openURLInTab since they rely on the BVC...
@rnewman
Copy link

rnewman commented Nov 13, 2015

Is there a reason not to keep one BVC alive per tab?

Is there a reason not to allow multiple HomeViewControllers, one for each time the home page appears in the navigation stack? I'm thinking of a future where we navigate into and out of web content, not just between web pages.

That is, TabManager owns (Tab, BVC)s. BVCs own a web view, a URL stack, and potentially that URL stack is actually URLs + home panels. Think about how we're going to implement navigating through a bookmark hierarchy, and hit Back in the final page and end up in the same folder, same scroll position…

@sleroux
Copy link
Author

sleroux commented Nov 13, 2015

Is there a reason not to keep one BVC alive per tab?

Nope. Keeping alive multiple BVCs within the 'TabManager' sounds better than just the 'Tab'. This way we don't keep to recreate views, can manage native/web content views, etc

Is there a reason not to allow multiple HomeViewControllers, one for each time the home page appears in the navigation stack?

Are you saying that since we would have multiple BVCs in the TabManager, we should also have multiple HomeViewControllers containing state?

In general, I like the idea of keeping BVCs/HomeViewControllers alive in memory which would increase perf since we're not reallocated/recreating things everytime. At the same time I worry about memory usage and how we would manage keeping many tabs alive with their HomeViewControllers as well. Trade offs I guess...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment