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

Fix GeckoView tile loading android assets folder #4478

Conversation

jwoodwardtfx
Copy link
Contributor

Fixes #4451

Joe Woodward added 3 commits July 31, 2024 13:23
@HarelM
Copy link
Collaborator

HarelM commented Jul 31, 2024

What about ajax.ts usage of file?

@jwoodwardtfx
Copy link
Contributor Author

No other changes are required. "file://" isn't referenced anywhere else in the code base, and, it's only this check that is causing an issue.

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.65%. Comparing base (c00a30b) to head (fbc8846).
Report is 3 commits behind head on main.

Files Patch % Lines
src/util/actor.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4478      +/-   ##
==========================================
- Coverage   87.84%   87.65%   -0.20%     
==========================================
  Files         246      246              
  Lines       33421    33421              
  Branches     2219     2205      -14     
==========================================
- Hits        29359    29295      -64     
- Misses       3043     3124      +81     
+ Partials     1019     1002      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Jul 31, 2024

See here:

const isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\w+:/.test(url));

I'll be surprised if this wouldn't need a patch as well...

@jwoodwardtfx
Copy link
Contributor Author

See here:

const isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\w+:/.test(url));

I'll be surprised if this wouldn't need a patch as well...

You are right, I was just looking at that line. However, if I just patch the one line in the commit, it all springs into life. I'll do a bit more digging. Thanks.

@jwoodwardtfx
Copy link
Contributor Author

See here:

const isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\w+:/.test(url));

I'll be surprised if this wouldn't need a patch as well...

You are right, I was just looking at that line. However, if I just patch the one line in the commit, it all springs into life. I'll do a bit more digging. Thanks.

It looks like the code is trying to avoid using the Fetch API when using "file://" and instead drop back to the legacy XMLHttpRequest.

It's not clear to me why, as I can't find anything in Mozilla Fetch API documentation (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or Chrome documentation (https://web.dev/articles/introduction-to-fetch) that states that the Fetch API can't work with a "file://" request (or "resource://android" in my case).

I've done some tests an using GeckoView on Android and both the Fetch API and XMLHttpRequest successfully load the fonts and glyphs.

I've had a quick look at Chromium on Windows too using "file://" and this is the same, both Fetch API and XMLHttpRequest seem to work fine.

So, I think this check is redundant, though, I'm not keen to back it out, even if not needed, as I assume it was added for an older browser than may not support "file://" access via the Fetch API? Removing it may cause a breakage for someone else, but, with a modern browser, it doesn't appear to be needed anymore.

@HarelM
Copy link
Collaborator

HarelM commented Jul 31, 2024

I can find old articles about fetch not supporting file protocol:
JakeChampion/fetch#92 (comment)
https://stackoverflow.com/questions/55133723/does-will-the-fetch-api-support-other-protocols-than-http

It might be that this is no longer relevant, IDK...

@jwoodwardtfx
Copy link
Contributor Author

If you agree, maybe the best option for now is to apply this fix for GeckoView, and the use of the Fetch API vs XMLHttpRequest can be looked at at a later point? A change to ajax.ts isn't needed to resolve the specific issue for GeckoView :)

Copy link
Collaborator

@HarelM HarelM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not.

@HarelM HarelM merged commit 19c79bb into maplibre:main Jul 31, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing to process map tiles in Android Webview when run from the "asset" folder
3 participants