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

web: Resolve URLs without a protocol in the extension player and improve error messages #16913

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Korne127
Copy link
Contributor

Currently, only URLs explicitly including the web protocol (HTTPS or HTTP) in the beginning can be resolved in the extension player. Additionally, if the URL doesn't include the HTTPS or HTTP protocol in the beginning, a wrong error is displayed. It states that the user ran Ruffle on the file: protocol which is wrong and confusing:
Bildschirmfoto 2024-06-28 um 15 53 04

This pull request fixes this.
With this pull request, the extension player resolves URLs without a protocol. It adds https:// or http:// if the URL is likely a valid web URL and file:/// if the URL is a valid file URL.
To determine whether HTTPS or HTTP should be used, Ruffle tests whether the server supports HTTPS. HTTP is only used if the server only supports HTTP and not HTTPS. This test happens while the loading screen is displayed.

This means that the user can now enter URLs without a leading https:// like you (usually) do in the browser.

Additionally, this pull request fixes and improves the error behaviour if the URL can't be resolved or used.
Instead of the wrong error, one of four more specific errors will be displayed:

  • One new error if the given URL is a local file URL:
    Bildschirmfoto 2024-06-28 um 15 56 26
  • One new error if the given URL uses a different protocol than https, http or file (e.g. ftp):
    Bildschirmfoto 2024-06-28 um 15 57 44
  • One new error if the given URL can't be resolved to any valid URL for any protocol
    Bildschirmfoto 2024-06-28 um 15 58 07
  • And the usual SWF file not found error if the file under the given web URL couldn't be found.
    That error has also been modified to also include the tip that the HTTP protocol should be (explicitly) used for websites that don't support HTTPS:
    Bildschirmfoto 2024-06-28 um 15 54 12

Also, a bug that caused the document title to not be set correctly if the SWF URL was the main page of a domain has been fixed. The handling of setting the document title of the extension player has generally been made more consistent.

@Croworbit
Copy link

hello Korne,
useful PR! :)
sorry but there is a typo on the 4th image!

@Korne127
Copy link
Contributor Author

Hey :)
Thanks for the nice response and the feedback :D
I'm sorry, but I genuinely don't see the typo… can you point it out for me? 😅

@Croworbit
Copy link

Hey :) Thanks for the nice response and the feedback :D I'm sorry, but I genuinely don't see the typo… can you point it out for me? 😅

"The url blabla test is no valid url"
I expected "the url blablatest is not a valid url"

@Korne127
Copy link
Contributor Author

Hmm, I would have thought that both is valid tbh, although the second one is probably better.
I can change it, but when I went back to look at the messages, I don't really like the repetition. I think I might change it to "Bla-Bla-Test is not a valid URL".
(And change enter to include on the last screenshot.)

@Croworbit
Copy link

amittedly its a nitpick 😅

@kjarosh kjarosh added the A-web Area: Web & Extensions label Jun 28, 2024
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from 699e67a to 86352c1 Compare June 29, 2024 12:56
@Korne127
Copy link
Contributor Author

@Croworbit Don't worry, I really appreciate it! Especially the things that I overlooked myself are good to know :)

@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from 86352c1 to 1621c78 Compare June 30, 2024 15:59
@evilpie evilpie added the waiting-on-review Waiting on review from a Ruffle team member label Jul 12, 2024
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from 1621c78 to e95d53c Compare July 26, 2024 14:25
@Korne127
Copy link
Contributor Author

I rebased the Pull Request and adapted it accordingly to @kjarosh's suggestions.

@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch 2 times, most recently from c648f07 to 2395f4d Compare July 26, 2024 21:55
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch 3 times, most recently from 71754a9 to 8ad6076 Compare July 26, 2024 23:59
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from fc91e68 to bd5d627 Compare August 9, 2024 15:09
@Korne127
Copy link
Contributor Author

Korne127 commented Aug 9, 2024

Extension-player specific error messages (as well as the http advice) are now only shown in the extension player, and a new additional error message is displayed if a website is misconfigured and uses a different protocol.

This is done by creating a so-called OriginAPI which allows the web core to access behaviour that's specific to the Ruffle origin (selfhosted, demo or extension).
For more information, see the last commit message.

Previously, only URLs explicitly including the web protocol (HTTPS or
HTTP) in the beginning could be resolved in the extension player.
This has been changed. The extension player now resolves URLs without a
protocol and adds https:// or http:// if the URL is likely a valid web
URL and file:/// if the URL is a valid file URL.
HTTP is only used if the server only supports HTTP and not HTTPS.
Previously, the Ruffle player had shown an incorrect error message if
the entered URL wasn't a valid web URL.
This has been fixed and improved. Three new error messages have been
added for this case: One in case the entered URL is a local file URL,
one in case the entered URL uses a different protocol than https, http
or file and one in case the entered URL isn't a valid URL for any
protocol at all.
Additionally, the error message in case Ruffle couldn't load the SWF
file (using a valid web URL) has been improved to also include the tip
that the HTTP protocol should be (explicitly) used for websites that
don't support HTTPS.
Previously, when entering a URL in the extension player, it had been
resolved before the loading screen had been displayed. As resolving can
include testing for server availability (to decide whether HTTPS or HTTP
is used), this could create a wait time without the loading screen.
This has been fixed. The loading screen is now displayed while the URL
is resolved. Additionally, the timeouts have been increased (they were
low because of the lack of a loading animation).

A bug that caused the document title to not be set correctly if the SWF
URL was the main page of a domain has also been fixed.
After entering a URL in the extension player, Ruffle resolves it,
potentially adding a protocol. This resolved URL is now displayed in the
URL input element instead of the original input URL.
This improves the transparency of which protocol is used and makes it
easier for the user to change it.
If Ruffle recognises that a URL is invalid or not supported, it now
doesn't try to connect to it, but instantly panics.
This reduces unnecessary connection attempts and improves reaction
speed.
The error messages outside the extension player have been fixed.
Ruffle now correctly determines whether the last load command originated
from the extension player and displays the error messages specific to it
(invalid URL / local URL / URL with unsupported protocol entered) only
in that case. The advice to try entering http explicitly has also been
removed if the URL is not loaded from the extension player.

Additionally, if the website now embeds a URL with an unsupported
protocol (e.g. file), a new specific error message about the website
being misconfigured is now displayed instead of a button to open the URL
in the extension player (which itself will result in an error).
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from bd5d627 to d85a8b5 Compare August 9, 2024 18:05
The new OriginAPI has been added to the web player.
It is used to access behaviour that's specific to the Ruffle origin
(selfhosted, demo or extension).
Unlike the SourceAPI, which manages the whole Ruffle polyfill and
player, it provides minor helper methods and is given to the (internal)
Ruffle player.

The OriginAPI has three implementations: SelfhostedOrigin, DemoOrigin
and ExtensionOrigin. The respective instance is created when installing
the Ruffle instance. When using SourceAPI#createPlayer or #polyfill, the
OriginAPI is given to the then-created (internal) player. This is done
by calling the new RufflePlayerElement#initialize method after creating
it.
The player API now also provides a method to access its OriginAPI.

The previous extension related variables and functions (like
inExtensionPlayer) have been removed from the core code. Instead,
createPanicError now uses OriginAPI calls to display the correct error
message.

Additionally, internalSourceApi and its usages have been replaced by
several functions, reducing the likelihood of future mistakes.

The documentation and code quality have also been generally improved.
@Korne127 Korne127 force-pushed the resolve-extension-player-urls branch from d85a8b5 to 66d9be3 Compare August 9, 2024 18:37
@danielhjacobs danielhjacobs added the T-feature Type: New Feature (that Flash doesn't have) label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions T-feature Type: New Feature (that Flash doesn't have) waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants