Closed Bug 1794982 Opened 3 years ago Closed 2 years ago

Unable to load page in asset pack

Categories

(GeckoView :: General, defect)

All
Android
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: thebigboss94ita, Unassigned)

Details

Attachments

(1 file)

Attached file script.txt

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

Steps to reproduce:

android studio, geckoview-omni:105.0.20221003135607
calling "session.loadUri("resource://android/assets/index.html")" to open index.html located in an asset pack.

Actual results:

GeckoView is unable to find index.html

Expected results:

GeckoView should've found and opened index.html. I contacted the developers on Matrix and they suggested me to rise a ticket here. Here's an extract of the chat:

johndoom
:) Hello there. I'm working on a html5 game on Android. I can't figure out how to access the index page with GeckoView, since the page is in an asset pack, can anyone give me some hints? The asset pack is set to be installed with the app and indeed it worked with WebViewer. I'm using "resource://android/assets/index.html" as uri, but no good. This is the script I'm using:

nalexander:
I strongly suspect that this is a detail of the Android asset pack process. The existing resource://android URL remapping is using an old Android technique to "map the APK". Other parts of the Android ecosystem won't be remapped, and I'm not aware of any way to tell GV about the location of such assets. If you, on the Android side, can get to a file:// URL, you should be able to at least get GV to see the assets... but you then may have origin issues because file:// URLs are special. To really solve this will require a BZ ticket and some thought about GV APIs that would allow the App to register additional known locations with GV.

The severity field is not set for this bug.
:cpeterson, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cpeterson)

(In reply to thebigboss94ita from comment #0)

calling "session.loadUri("resource://android/assets/index.html")" to open index.html located in an asset pack.

Actual results:

GeckoView is unable to find index.html

Does GeckoView return an error message with any more details?

Fenix's Android-Components library successfully loads HTML files (for network error pages) from resource://android/assets/. Those URIs are created here:

https://github.com/mozilla-mobile/android-components/blob/bb489ef682b33e8ebc770908bfe06befb13b0dd6/components/browser/errorpages/src/main/java/mozilla/components/browser/errorpages/ErrorPages.kt#L78-L90

And then loaded here:

https://github.com/mozilla-mobile/android-components/blob/bb489ef682b33e8ebc770908bfe06befb13b0dd6/samples/browser/src/main/java/org/mozilla/samples/browser/request/SampleUrlEncodedRequestInterceptor.kt#L68

Severity: -- → S3
Flags: needinfo?(cpeterson)
Summary: android, unable to load page in asset pack → Unable to load page in asset pack

(In reply to thebigboss94ita from comment #0)

I tried your code in a new project in Android Studio, and it works as expected. I even used the same GV version you posted here.
Can you re-check if you correctly added the html file in the location you provided in the code?

Also, can you attach the webpage you are trying to open?

thebigboss94ita, if you can still reproduce this problem in the latest version of GV, we can reopen this bug.

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: