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

Failing to process map tiles in Android Webview when run from the "asset" folder #4451

Closed
jwoodwardtfx opened this issue Jul 25, 2024 · 5 comments · Fixed by #4478
Closed
Labels
enhancement New feature or request PR is more than welcomed Extra attention is needed

Comments

@jwoodwardtfx
Copy link
Contributor

In Actor.receive() there is a check for the origin/location.

However, if running on Android using some WebView implementations (such as Mozilla's GeckoView) and running from the Android asset folder (which is really just "file://"), the data.origin is actually set to "resource://android".

That is, the following line:
if (data.origin !== 'file://' && location.origin !== 'file://' && data.origin !== location.origin) {

Should be extended to be:
if (data.origin !== 'file://' && location.origin !== 'file://' && data.origin !== 'resource://android' && location.origin !== "resource://android" && data.origin !== location.origin) {

As, otherwise, no map tiles are loaded and displayed.

Many thanks.

@HarelM
Copy link
Collaborator

HarelM commented Jul 25, 2024

I'm using Capacitor, and it doesn't have this issue. I would suggest creating a small webserver on android like done with Capacitor to solve this issue.
file:// are handled correctly in the current code, can you configure the webview to no use "resource://"?

@HarelM HarelM added the need more info Further information is requested label Jul 25, 2024
@jwoodwardtfx
Copy link
Contributor Author

I appreciate this may be an issue specific to GeckoView and a Chromium-based WebView may be fine, but, why not support both?

It seems overkill to have to implement a webserver when the intention appears to be to support file:// based access, it's just using Mozilla on Android, this presents with the origin as "resource://android" rather than "file://".

@HarelM
Copy link
Collaborator

HarelM commented Jul 27, 2024

Can you configure GeckoView to behave like a "regular" browser and serve files with the "file://" protocol? This is not the only place where file protocol is checked and expected, and I don't think there's a need to patch all these places because the GeckoView decided to implement this differently from other browsers...

@jwoodwardtfx
Copy link
Contributor Author

I'm afraid not. If Firefox or GeckoView are to be supported, a change needs to be made.

It looks like this code was already modded to make it work with Chrome/Chromium in:
#3680

It just needs a tweak to work with Firefox/GeckoView too.

Interestingly, this used to work pre v4 just fine. It looks like this change:
#3329

Due to this issue:
#3239

...broken file access using Firefox.

@HarelM
Copy link
Collaborator

HarelM commented Jul 30, 2024

The two places I know that use file protocol are in ajax code and the actor.
But there might be other places.
Feel free to open a PR.

@HarelM HarelM added enhancement New feature or request PR is more than welcomed Extra attention is needed and removed need more info Further information is requested labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR is more than welcomed Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants