Closed Bug 1041633 Opened 10 years ago Closed 6 years ago

[geckoview] Allow disconnecting and reconnecting a GeckoView to a running Gecko

Categories

(GeckoView :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: nalexander, Unassigned)

References

Details

At the moment, GeckoView is very difficult to use in an embedding application because there is a strong assumption that only a single static GeckoView exists at one time.  Fennec itself jumps through hoops -- effectively opting-out of the Android platform View, Fragment, and Activity lifecyles -- in order to maintain this invariant.

Requiring embedding applications to do the same is both undocumented and undesirable.  Our own examples, such as https://github.com/mfinkle/geckobrowser and https://github.com/ncalexan/geckobrowser-gradle, don't do this, and fail when the Activity is killed and restarted.

We may never support multiple *active* GeckoViews (Bug 889994), but we should find a way to make our GeckoView examples work across the Activity lifecycle.
Some notes on this:

In discussions with lucasr, we came to the conclusion that a singleton Android View is essentially impossible.  The platform creates and destroys View classes regularly, and uses this mechanism to handle every configuration change.  I wondered if a singleton Fragment was possible, and lucasr clarified that a singleton /Fragment/ might be possible, but the underlying Views are still created and destroyed on configuration changes.  So neither of these options helps us participate in the Android Activity lifecycle without manually managing configuration changes.

We could also make GeckoView extend a "Gecko Activity" of some sort.  This is not a standard Android extension point for a number of reasons.  It's very unlikely that we could migrate Fennec itself (GeckoApp and/or BrowserApp) to extend from a GeckoViewActivity in a reasonable amount of time.
In discussions with snorp, we talked about his work on making Gecko run headless (Bug 834033).

snorp was of the opinion that maintaining a hidden background window across the Gecko process lifecyle was feasible.  That is, Gecko would never be window-less; GeckoViews could come, connect to a visible window, and leave (disconnecting from the visible window) as needed.

snorp felt that disconnecting a GeckoView from a running Gecko would not be too difficult.  The hard part is that large swaths of Fennec assume that there is a unique GeckoView; in particular, there's a delicate balance whereby GeckoAppShell and browser.js provide Gecko features.  It's likely that the JavaScript <-> Java bridge is the hard thing to get right here, since we don't (necessarily) want to tear down the Gecko <window> when the active GeckoView disconnects.  We'd like to be able to maintain our browsing Gecko context across device rotations, for example.
Mass change of bugs in the "Embedding: GRE Core" component in preparation for archiving it. I believe that these are no longer relevant; but if they are, they should be reopened and moved into a component relevant to the code in question.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
Product: Core → Core Graveyard
Reopening and moving to Core::Embedding: APIs, where we'll continue to triage and track GeckoView issues.
Status: RESOLVED → REOPENED
Component: Embedding: GRE Core → Embedding: APIs
Product: Core Graveyard → Core
Resolution: INCOMPLETE → ---
Component: Embedding: APIs → GeckoView
Product: Core → Firefox for Android
Version: unspecified → Trunk
This works today via the GeckoView(Display) / GeckoSession split.
Status: REOPENED → RESOLVED
Closed: 8 years ago6 years ago
Resolution: --- → WORKSFORME
Product: Firefox for Android → GeckoView
You need to log in before you can comment on or make changes to this bug.