Closed Bug 1621480 Opened 6 years ago Closed 6 years ago

GeckoSession.HistoryDelegate.onHistoryStateChange is not fired unless GeckoSession.ProgressDelegate.onSessionStateChange is set

Categories

(GeckoView :: General, defect, P2)

76 Branch
Unspecified
All
defect

Tracking

(firefox77 fixed)

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: staleydyla.n, Assigned: owlish, NeedInfo)

Details

Attachments

(2 files)

Attached file MainActivity.kt

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36

Steps to reproduce:

  • Create a GeckoSession without attaching a ProgressDelegate
  • Load a webpage with links to another page
  • Navigate to another page

Actual results:

onHistoryStateChange handler is not fired on navigation

Expected results:

onHistoryStateChange should be fired, logging "currentIndex: 1"

Attaching the ProgressDelegate (by uncommenting line 33) and performing navigation results in the onHistoryStateChange handler being correctly fired

Rank: 20
Assignee: nobody → bugzeeeeee

On the subsequent navigations, is onHistoryStateChange fired? Is currentIndex incremented or does it stay 0 all the time?

Flags: needinfo?(staleydyla.n)

(In reply to [:owlish] from comment #2)

On the subsequent navigations, is onHistoryStateChange fired? Is currentIndex incremented or does it stay 0 all the time?

onHistoryStateChange is never fired. I don't think I can check currentIndex since that's a property of the HistoryList, and since the callback is never fired I don't have access to that.

Flags: needinfo?(staleydyla.n)

I have some more questions. What happens when you do have progressDelegate? (like, when that line is uncommented) Does onHistoryStateChange behave correctly?
Also, can you tell us a bit more about your use case? It seems important for you not to have progressDelegate in there

Flags: needinfo?(staleydyla.n)

(In reply to [:owlish] from comment #4)

I have some more questions. What happens when you do have progressDelegate? (like, when that line is uncommented) Does onHistoryStateChange behave correctly?
Also, can you tell us a bit more about your use case? It seems important for you not to have progressDelegate in there

Yes, when the progressDelegate is set (so the line is uncommented), the onHistoryStateChange callback is fired correctly on all navigation events.

As far as use case goes, I don't mind having a progressDelegate set, but based on comments on Matrix it sounds like it shouldn't be necessary. https://matrix.to/#/!kgzqJPKsBZFakDVGxV:mozilla.org/$DcCMHjyZvEwYkmshs838X0CMGz0mXKMeMn6BsU7PPic?via=mozilla.org&via=matrix.org&via=matrix.rmed.dev

Originally, I was using onHistoryStateChange to check if the back-stack was empty, but I've switched to using onCanGoBack instead. I wanted to file this issue though since it sounded like onHistoryStateChange should work without a progressDelegate.

Flags: needinfo?(staleydyla.n)

Move the history state logic to history delegate handler to separate progress delegate and history delegate

Attachment #9138422 - Attachment description: Bug 1621480 - Add smaller test for onHistoryStateChange → Bug 1621480 - Separate progress delegate and history delegate while avoiding race conditions
Pushed by jwillcox@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cd5ac7f5ef15 Separate progress delegate and history delegate while avoiding race conditions r=geckoview-reviewers,snorp

Hey, the patch has landed - can you please confirm it's working for you now?

Edit: I realized immediately it probably wasn't released yet. I guess we have to wait for the release and then confirm the patch works

Flags: needinfo?(staleydyla.n)
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: