Android WebView - Load local image

  • Hello,

    I'm developing a Xamarin.Forms application, which contains a WebView that holds krpano HTML5 viewer. I'm focusing on Android 7.1 right now.
    The goal is to implement a simple 360 panora viewer, so the xml config file is very simple : just a simple sphere component.
    If the image is loaded from internet, everything works fine and easy (but if I need to specific html5: "always" to make it work, and localfallback: "none" to remove the "file:///" warning).

    But the hard part is when loading image from the local device drive, using the "file://" protocol.
    It simply won't work, showing just black, no error message...
    To be sure it isn't a file access permission problem, I've added a <img> component in the html pointing the exact same image locally and it work just fine.
    To be sure it isn't a javascript permission problem, I've tried to load the same image not using the scr tag of <img>, but using a small js script, and it work just fine.

    So know I have no lead or no idea why krpano doesn't want to load the picture, and I've isolated the problem to be sure it's coming from krpano and not another component.

    To help please find a simple source code below. Please note that for simplicity, I've embedded the xml into the html to remove one file (works fine with a online image).

    Do you have any ideas how to solve that not-so-simple problem ?
    (I'm using krpano-1.19-pr14)

    Thanks.
    Nicolas.

  • For debug purposes, I've extracted the xml to a file, saving it in the app's directory, and the same for the krpano.js file.
    The js file load successfully as it shows a black screen with an error message :

    Quote

    "FATAL ERROR : krpano.xml - loading failed! (0)"

    And here is more details from the console :

    Quote

    [INFO:CONSOLE(1)] "Failed to load file:///data/user/0/http://com.something.app/files/krpano/krpano.xml: Cross origin requests are only supported for protocol schemes: http, data, chrome, https.", source: (1)03-19 10:45:04.980 I/chromium( 1222): [INFO:CONSOLE(1)] "Failed to load file:///data/user/0/http://com.something.app/files/krpano/krpano.xml: Cross origin requests are only supported for protocol schemes: http, data, chrome, https.", source: (1)

    Maybe it's a lead ?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!