Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on webContents.history #2836

Merged
merged 1 commit into from
Oct 22, 2022
Merged

Conversation

aycyang
Copy link
Contributor

@aycyang aycyang commented Jul 28, 2022

The history field of Electron's webContents module is no longer present
beyond Electron 10, so we have to stop using it in order to upgrade.

webContents.history is used to manage a subset of browsing history
within the app. My observation is that the global history (which
includes itch:// URLs) is a superset of the webContents.history, so the
theory is that we could rely entirely on the global history and
back-forward navigation would work just as well.

Closes #2598

@aycyang
Copy link
Contributor Author

aycyang commented Jul 28, 2022

I tested this manually and back-forward navigation seems to work almost as well as before. I did notice that this introduces a minor bug which is that you can't (easily) go back from the Explore page; it goes to https://itch.io and then back to https://itch.io/. I figured I would still publish what I have since this new minor bug has workarounds, and/or in case someone can figure out a fix for it and/or is willing to accept this new bug in exchange for actually being able to run the app on Electron 11 without crashing right away.

Also it occurs to me that deleting this much code is pretty fishy, even to me. If I'm way out of line, I wouldn't be surprised. But this just seemed like the easiest path forward.

The history field of Electron's webContents module is no longer present
beyond Electron 10, so we have to stop using it in order to upgrade.

webContents.history is ostensibly used to manage a subset of browsing
history. My observation is that the global history (which includes
itch:// URLs) is a superset of the webContents.history, so the theory is
that we could rely entirely on the global history and back-forward
navigation would work just as well.

This commit introduces a new bug: after entering a URL such as
`http://itch.io` into the address bar, the app will change the URL to
`https://itch.io/` (note the change in protocol and the added trailing
slash), and the history will end up with two entries when there should
be only one. This means that going back from `https://itch.io/` will
navigate to `http://itch.io` only to loop you back to
`https://itch.io/`, rendering the back button useless in this particular
scenario. I can't figure out how to fix this correctly, so to work
around this in the common case, I'm changing the URL of the Explore
sidebar entry so that at least the itch.io homepage won't have this
problem.

Closes itchio#2598
@aycyang
Copy link
Contributor Author

aycyang commented Aug 6, 2022

Updated this PR with 3 changes:

  • Updated commit message to describe the new bug (back button ineffective if URL morphs)
  • Added workaround specifically for the Explore sidebar entry so that it doesn't suffer from the new bug
  • Removed did-navigate-in-page hooks so that embedded URLs don't get added to the history (noticed this in a devlog on itch.io, tested with https://help.twitter.com/en/using-twitter/how-to-embed-a-tweet)

At this point the only problem is that if you manually type a URL (e.g. example.com) and press back, it effectively reloads the page you're on. The workaround (not ideal) is right-clicking the back button and selecting the second entry in the dropdown menu.

@leafo
Copy link
Member

leafo commented Oct 22, 2022

Thanks for the contribution. I also spent time time investigating this. I think that at this point working on getting electron updated is more important that the bug that's left from removing the custom navigation code. There's a lot of refactoring that needs to take place going forward but I'm happy to accept this so we can push out a build with electron 11 at least.

@leafo leafo closed this Oct 22, 2022
@leafo leafo reopened this Oct 22, 2022
@leafo leafo merged commit 58a6f93 into itchio:master Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐧 Feedback v25.4.9-canary
2 participants