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
- Acts as a singleton
- Never is deallocated
- Contains all opened web views in hierarchy
- Relies on TabManager's selectedTab property to determine what to show and how to configure itself
- This is why we have so many conditionals everywhere and check state so much
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L627
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L685
- https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Browser/BrowserViewController.swift#L759
- Seriously, it's almost in every method
(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...
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
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...