Issue #1039: Use browser-engine-system and feature-session components to replace WebView abstraction layer.. #1044
Conversation
| override fun name(): String { | ||
| throw NotImplementedError() | ||
| } | ||
| val sessionUseCases = SessionUseCases(sessionManager) |
mcomella
Aug 30, 2018
Contributor
nit: by lazy? Otherwise engine and sessionManager will make themselves right now.
nit: by lazy? Otherwise engine and sessionManager will make themselves right now.
pocmo
Aug 31, 2018
Author
Contributor
Oh, yeah, good catch!
Oh, yeah, good catch!
Unless we can land something tomorrow. :) |
|
Alternatively... @pocmo How much is changing for the final PR? Provided the changes aren't too big, I can look over the most recent WIP tomorrow, Severin can look at it next week and land it, and I can look at it to make sure we didn't miss anything when I come back. That way we can get it in sooner and test earlier. What do you think? |
For this iteration not much. Components 0.21 should get released today and then with that I should be able to look at the three missing pieces mentioned above. The patches for tracking protection and URL interception landed in a-c. Fullscreen API is at risk for 0.21 because the PR is not up yet. We may need to ship that with 0.22 or can ship a 0.21.1 if this gets in early next week.
Depending on what you and @Baron-Severin think I'd be open to land this as-is (with review comments addressed) and open separate PRs for the next pieces. The idea is to unblock others by having to wait on a big code drop and to be able to have others test and iterate on the new code. The drawback is that we temporarily have a not 100% feature complete app though (-> at least the three points mentioned above). Apart from that the app seems to be "fully" functional in my tests. |
c118132
to
8b0e857
|
Updated the PR. Made all checks pass (ktlint, detekt, checkstyle, lint), SessionUseCases initializes lazily now and cleaned up some of the code. |
|
A few things missing here or there and a few nits but otherwise lgtm. I find the Some other things that have changed – please file a bug or fix:
Not sure it was related to your changes but I got into a state where a white page was loaded and the progress bar was shown without a URL (i.e. empty str or null) after going backwards and forwards a few times.
Me too: please send an email to the team letting them know 1) this is landing, 2) the features that need follow-ups, and 3) that they'll need to change their build variant. Also, don't forget to file issues to track this work! :) @Baron-Severin FYI that this may land. |
| * component is powerful enough.. | ||
| */ | ||
| @Suppress("DEPRECATION") | ||
| fun EngineView.setupForApp(context: Context) { |
mcomella
Sep 1, 2018
Contributor
Add @SuppressLint("SetJavaScriptEnabled") // We explicitly want to enable JavaScript
Add @SuppressLint("SetJavaScriptEnabled") // We explicitly want to enable JavaScript
...src/amazonWebview/java/org/mozilla/focus/webview/FirefoxAmazonWebView.kt
Show resolved
Hide resolved
| @@ -194,6 +192,35 @@ class BrowserFragment : IWebViewLifecycleFragment(), Session.Observer { | |||
| return layout | |||
| } | |||
|
|
|||
| var sessionFeature: SessionFeature? = null | |||
mcomella
Sep 1, 2018
Contributor
nit: move to top of class
nit: move to top of class
|
|
||
| // The SessionFeature implementation will take care of making sure that we always render the currently selected | ||
| // session in our engine view. | ||
| sessionFeature = SessionFeature( |
mcomella
Sep 1, 2018
Contributor
Should be nulled in onDestroyView because it has a reference to a view
Should be nulled in onDestroyView because it has a reference to a view
| @@ -194,6 +192,35 @@ class BrowserFragment : IWebViewLifecycleFragment(), Session.Observer { | |||
| return layout | |||
| } | |||
|
|
|||
| var sessionFeature: SessionFeature? = null | |||
|
|
|||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |||
mcomella
Sep 1, 2018
Contributor
nit: I don't love using onCreateView and onViewCreated in the same file: I think the relationship between them isn't intuitive (basically that onViewCreated is only for using the new WebView reference) and devs will put content in them interchangeably (even experienced devs might overlook this).
I'd prefer to make onViewCreated final in the super class and define a new abstract method like, onCreateViewWithWebView or something.
nit: I don't love using onCreateView and onViewCreated in the same file: I think the relationship between them isn't intuitive (basically that onViewCreated is only for using the new WebView reference) and devs will put content in them interchangeably (even experienced devs might overlook this).
I'd prefer to make onViewCreated final in the super class and define a new abstract method like, onCreateViewWithWebView or something.
pocmo
Sep 3, 2018
Author
Contributor
I introduced a method onWebViewCreated(webView: EngineView) that will be called from EngineViewLifecycleFragment.onViewCreated() and moved the code to onWebViewCreated in BrowserFragment.
I introduced a method onWebViewCreated(webView: EngineView) that will be called from EngineViewLifecycleFragment.onViewCreated() and moved the code to onWebViewCreated in BrowserFragment.
|
fwiw, I am a little concerned that we're rushing this and should maybe wait until the next release. We merged the home screen into the navigation overlay, which isn't stable yet, and we're landing this complex refactor (whose components haven't been used in a production app before) into that. For example, there are regressions in back/forward state that I couldn't reproduce consistently and I'm not sure who is to blame; debugging may get complicated when there's so much changing at once! That being said, we can't expect this to land without bugs, the components are well tested in isolation, and it's pretty important to get the components tested in production sooner rather than later so we can add them to our other projects. Perhaps we should land but not hesitate to back it out if it causes problems? What do you think @pocmo ? If so, let's ask QA to start testing this as soon as it lands. Note that Chenxia, Severin, and I won't be working on this next week so we'll have fewer people around if something goes wrong and after that we only have two weeks to iron out any issues. @liuche @Baron-Severin Please share if you have any thoughts! |
|
From the migration I feel like the overlay and the things touching the engine are pretty well separated. We are definitely introducing risk with the migration but it doesn't feel like it gets worse by having both things (engine migration + overlay migration) happen at the same time.
Yeah, that's a chicken egg problem. FFFTV is the first candidate because the feature set is the smallest and the first milestone we have reached. :)
I noticed that there is a regression because we can't intercept "firefox:home" and inject custom content. With that the page is not in the history stack and breaks some of the logic. The functionality for that landed in 0.21 - I added an item about testing back/forward after that to #1063.
Yeah, that sounds good to me. It will get more complicated to back out later on after we added more commits on top of it though. I'll talk to QA once this lands. :) |
|
Had a few questions, nothing major. LGTM |
| @@ -13,7 +13,7 @@ android { | |||
| compileSdkVersion 27 | |||
|
|
|||
| defaultConfig { | |||
| applicationId "org.mozilla.tv" | |||
| applicationId "org.mozilla.tv.firefox" | |||
severinrudie
Sep 4, 2018
Contributor
Nit: Why are we changing the app ID? Is there an issue that explains this?
Nit: Why are we changing the app ID? Is there an issue that explains this?
pocmo
Sep 5, 2018
Author
Contributor
Previously we had product flavors for the engine and those flavors added a suffix:
roductFlavors {
amazonWebview {
applicationIdSuffix ".firefox"
// [..]
}
gecko {
applicationIdSuffix ".gecko"
// [..]
}
}
We have been shipping the amazonWebview flavor only. Now that the flavor is gone I moved the suffix to the applicationId setup directly.
Previously we had product flavors for the engine and those flavors added a suffix:
roductFlavors {
amazonWebview {
applicationIdSuffix ".firefox"
// [..]
}
gecko {
applicationIdSuffix ".gecko"
// [..]
}
}We have been shipping the amazonWebview flavor only. Now that the flavor is gone I moved the suffix to the applicationId setup directly.
| private fun initAmazonFactory() { | ||
| if (!isAmazonFactoryInit) { | ||
| factory = AmazonWebKitFactories.getDefaultFactory() | ||
| if (factory!!.isRenderProcess(this)) { |
severinrudie
Sep 4, 2018
Contributor
I love how much code this PR deletes.
I love how much code this PR deletes.
| val actionBar = supportActionBar | ||
| if (actionBar != null) { | ||
| actionBar.setDisplayHomeAsUpEnabled(true) | ||
| actionBar.setDisplayShowHomeEnabled(true) |
severinrudie
Sep 4, 2018
Contributor
Nit: we could avoid capturing the actionBar variable here by using apply or similar.
Nit: we could avoid capturing the actionBar variable here by using apply or similar.
pocmo
Sep 5, 2018
Author
Contributor
That's a good idea and avoids some repetition. I'll update the PR.
That's a good idea and avoids some repetition. I'll update the PR.
… to replace WebView abstraction layer. As a side effect: * Replaces AmazonWebView with WebView (Issue #379) * Removes the product flavor dimensions that are not needed anymore.

@mcomella @Baron-Severin I want to share the current state of the migration to use
browser-engine. This version is functional and you can use it to browse the web. Like with thebrowser-sessionintegration I used extension functions to work around functionality that is not available in the upstream components.Missing pieces without a workaround in this version (list may be incomplete):
This functionality is scheduled to land in 0.22 (next week). However I may move this into the current sprint so that we can have this in 0.21 on Friday.We moved this into the 0.21 sprint and the functionality should be available in 0.21.Added follow-up items to: #1063
As a side effect: