GeckoView: Expose "history stack" of a session and allow navigating to index
Categories
(GeckoView :: General, enhancement, P1)
Tracking
(firefox-esr60 wontfix, firefox65 wontfix, firefox66 wontfix, firefox67 wontfix, firefox68 fixed)
People
(Reporter: sebastian, Assigned: droeh)
References
()
Details
(Whiteboard: [gvtv:p1] [geckoview:fenix:m2])
Attachments
(2 files)
| Reporter | ||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 1•7 years ago
•
|
||
Updated•7 years ago
|
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
What do people think about the following API?
interface HistoryDelegate {
...
void onHistoryListUpdate(String[] uris, int currentIndex);
}
class GeckoSession {
...
void goto(int index);
}
Instead of an array of String in onHistoryListUpdate we could have a HistoryItem which would look a lot like the arguments to HistoryDelegate.onVisited, which looks like:
@Nullable GeckoResult<Boolean> onVisited(@NonNull GeckoSession session,
@NonNull String url,
@Nullable String lastVisitedURL,
@VisitFlags int flags)
In particular, I think the flags would be useful in onHistoryListUpdate. The WebView history item[0] has some stuff like title and favicon, but I don't think those really belong here.
[0] https://developer.android.com/reference/android/webkit/WebHistoryItem
Comment 4•7 years ago
|
||
Do we need onVisited if we have onHistoryListUpdate? (I'm assuming lastVisitedURL would be uris[currentIndex + 1] on the new API)
| Assignee | ||
Comment 5•7 years ago
|
||
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #3)
What do people think about the following API?
interface HistoryDelegate { ... void onHistoryListUpdate(String[] uris, int currentIndex); } class GeckoSession { ... void goto(int index); }Instead of an array of
StringinonHistoryListUpdatewe could have aHistoryItemwhich would look a lot like the arguments toHistoryDelegate.onVisited, which looks like:@Nullable GeckoResult<Boolean> onVisited(@NonNull GeckoSession session, @NonNull String url, @Nullable String lastVisitedURL, @VisitFlags int flags)In particular, I think the flags would be useful in
onHistoryListUpdate. TheWebViewhistory item[0] has some stuff like title and favicon, but I don't think those really belong here.[0] https://developer.android.com/reference/android/webkit/WebHistoryItem
In my opinion, GeckoSession.goto() is a pretty vague name; WebView uses goBackOrForward which is a bit verbose but a lot clearer. Also, assuming that onHistoryListUpdate and goto use the same indexing scheme, this requires the app to store the current index in order for goto to be useful in most cases; having goto use relative indexing (so that the current history entry is index 0) makes goto a bit more useful on its own.
Also, I know it's come up before, but I think this is a good time to reconsider having canGoBack(), canGoForward(), and maybe something like gotoRange() (which would give the range of valid input for goto) so the app doesn't have the overhead of maintaining these and the possible bugs associated with getting them out of sync. I suppose you could add something like currentHistoryIndex() in here as well to address the indexing issue above.
Updated•7 years ago
|
Comment 6•7 years ago
|
||
Sebastian, does this history API need to be synchronous?
Comment 7•7 years ago
•
|
||
(In reply to Dylan Roeh (:droeh) from comment #5)
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #3)
What do people think about the following API?
interface HistoryDelegate { ... void onHistoryListUpdate(String[] uris, int currentIndex); } class GeckoSession { ... void goto(int index); }Instead of an array of
StringinonHistoryListUpdatewe could have aHistoryItemwhich would look a lot like the arguments toHistoryDelegate.onVisited, which looks like:@Nullable GeckoResult<Boolean> onVisited(@NonNull GeckoSession session, @NonNull String url, @Nullable String lastVisitedURL, @VisitFlags int flags)In particular, I think the flags would be useful in
onHistoryListUpdate. TheWebViewhistory item[0] has some stuff like title and favicon, but I don't think those really belong here.[0] https://developer.android.com/reference/android/webkit/WebHistoryItem
In my opinion,
GeckoSession.goto()is a pretty vague name; WebView usesgoBackOrForwardwhich is a bit verbose but a lot clearer.
Yeah. Maybe gotoHistoryIndex? I guess goBackOrForward works too.
Also, assuming that
onHistoryListUpdateandgotouse the same indexing scheme, this requires the app to store the current index in order forgototo be useful in most cases; havinggotouse relative indexing (so that the current history entry is index 0) makesgotoa bit more useful on its own.
Maybe instead of a separate array/index pair we just have a List subclass that includes the current index? That way the app can just store a reference to that whole thing. For relative navigation I was thinking we would just add an overload for goForward and goBack that take an offset. So goBack(2) will go back two spots in the list. goBack() would chain to goBack(1), etc.
Also, I know it's come up before, but I think this is a good time to reconsider having
canGoBack(),canGoForward(), and maybe something likegotoRange()(which would give the range of valid input forgoto) so the app doesn't have the overhead of maintaining these and the possible bugs associated with getting them out of sync. I suppose you could add something likecurrentHistoryIndex()in here as well to address the indexing issue above.
I think that's part of a larger philosophical discussion of "should we save state in GeckoSession". I still don't think we need that, but we should instead fire initial events for things like onCanGoBack.
| Assignee | ||
Comment 8•7 years ago
|
||
Some further thoughts on this:
I think the "history stack" object is very similar to a saved state in practice, and possibly we should be using the same underlying representation for both (albeit perhaps with different exposed interfaces?).
Likewise, from an implementation standpoint, onHistoryListUpdate is essentially just a subset of the state saved callback (let's tentatively say onStateSaved); onHistoryListUpdate should be called whenever onStateSaved is called due to navigation (but not for scrolling or form data changes).
Those things considered, I think this bug should be viewed as pretty closely related to bug 1463878
(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) from comment #7)
Also, assuming that
onHistoryListUpdateandgotouse the same indexing scheme, this requires the app to store the current index in order forgototo be useful in most cases; havinggotouse relative indexing (so that the current history entry is index 0) makesgotoa bit more useful on its own.Maybe instead of a separate array/index pair we just have a
Listsubclass that includes the current index? That way the app can just store a reference to that whole thing. For relative navigation I was thinking we would just add an overload forgoForwardandgoBackthat take an offset. SogoBack(2)will go back two spots in the list.goBack()would chain togoBack(1), etc.
I would suggest we expand onCanGoBack and onCanGoForward to supply ints indicating how far back/forward you can navigate, in that case. Also, if we have relative navigation with goBack and goForward, do we actually need goto at all? The case for absolute navigation seems pretty thin imo.
Also, I know it's come up before, but I think this is a good time to reconsider having
canGoBack(),canGoForward(), and maybe something likegotoRange()(which would give the range of valid input forgoto) so the app doesn't have the overhead of maintaining these and the possible bugs associated with getting them out of sync. I suppose you could add something likecurrentHistoryIndex()in here as well to address the indexing issue above.I think that's part of a larger philosophical discussion of "should we save state in
GeckoSession". I still don't think we need that, but we should instead fire initial events for things likeonCanGoBack.
In what circumstances would we fire initial events? I thought we already did when loading a saved state, are there other cases?
Comment 9•7 years ago
|
||
I think the "history stack" object is very similar to a saved state in practice, and possibly we should be using the same underlying representation for both (albeit perhaps with different exposed interfaces?).
I think I'd agree with that line of thinking.
Also, if we have relative navigation with
goBackandgoForward, do we actually needgotoat all? The case for absolute navigation seems pretty thin imo.
I'd think that for things like the session history popup it would feel much more natural to ideally just call goto with the index of the item that was selected instead of having to calculate a relative offset to the current history entry and then deciding whether that needs to be passed to goBack or to goForward.
Comment 10•7 years ago
|
||
P1 and [geckoview:fenix:m2] because this history feature is a must-have for Fenix M2:
Comment 11•7 years ago
|
||
Dylan said he would look at this bug as part of his work on the new saveState API.
Comment 12•7 years ago
|
||
[geckoview:fenix:m2] not [geckoview:fenix:p1]
Updated•7 years ago
|
| Assignee | ||
Comment 14•7 years ago
|
||
| Assignee | ||
Comment 15•7 years ago
|
||
Depends on D24439
Updated•7 years ago
|
| Reporter | ||
Updated•7 years ago
|
Comment 16•7 years ago
|
||
67=wontfix. Fenix MVP will use GeckoView 68, so we don't need to uplift this fix to 67 Beta.
Updated•7 years ago
|
Comment 17•7 years ago
|
||
Comment 18•7 years ago
|
||
Backed out for failing geckoview
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=239707663&repo=autoland&lineNumber=1966
Backout: https://hg.mozilla.org/integration/autoland/rev/15f3d68875c0d0855a7fdff26ca54d4ce262d03f
Comment 19•7 years ago
|
||
| Assignee | ||
Comment 20•7 years ago
|
||
(In reply to Andreea Pavel [:apavel] from comment #18)
Backed out for failing geckoview
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=239707663&repo=autoland&lineNumber=1966
Backout: https://hg.mozilla.org/integration/autoland/rev/15f3d68875c0d0855a7fdff26ca54d4ce262d03f
Forgot to clear hanging onHistoryStateChange callbacks after each test and introduced some raciness. Should be good now (at least it looks good locally.)
Comment 21•7 years ago
|
||
Backed out for geckoview failures on HistoryDelegateTest
Push that started the failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&revision=1bc29703a90ff8dc7d480cbae976cb02591be4a8&selectedJob=239729164
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=239729164&repo=autoland&lineNumber=1941
Backout: https://hg.mozilla.org/integration/autoland/rev/55c2f04c1751ae9d237646cb114b2533b86fc026
Comment 22•7 years ago
|
||
Comment 23•7 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/9a8350404d6c
https://hg.mozilla.org/mozilla-central/rev/bc0600ed24ce
| Assignee | ||
Updated•7 years ago
|
Description
•