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

WEBP image errors on Windows #62

Open
SKBotNL opened this issue Apr 25, 2023 · 13 comments
Open

WEBP image errors on Windows #62

SKBotNL opened this issue Apr 25, 2023 · 13 comments

Comments

@SKBotNL
Copy link

SKBotNL commented Apr 25, 2023

Expected Behavior

The resource should load

Current Behavior

When using an external image/web address as the resource of an image the built program for Windows errors with:
haxe/ui/backend/AssetsImpl.hx:95: [IOErrorEvent type="ioError" bubbles=true cancelable=false text="Unknown error" errorID=0]

Steps to Reproduce (for bugs)

  1. Create an Image
  2. Build the project for Windows
  3. See error

Test app / minimal test case

package;

import haxe.ui.containers.VBox;
import haxe.ui.components.Image;
import haxe.ui.HaxeUIApp;

class Main {
    public static function main() {
        var app = new HaxeUIApp();
        app.ready(function() {
            var vbox = new VBox();
            vbox.percentHeight = 100;
            vbox.percentWidth = 100;

            var image = new Image();
            image.resource = "https://cdn.discordapp.com/icons/613425648685547541/a_08b73e86d3c5661db3e397e4c557f751.webp";
            image.width = 128;
            image.height = 128;

            vbox.addComponent(image);
            app.addComponent(vbox);
            app.start();
        });
    }
}

Your Environment

  • Version used: 1.6.0
  • Operating System and version (desktop or mobile): Windows 10
@SKBotNL SKBotNL changed the title AssetsImpl errors on Windows Image with external resource errors on Windows Apr 25, 2023
@ianharrigan
Copy link
Member

Does it happen with, for example, png images?

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

Does it happen with, for example, png images?

PNGs don't seem to even load.

@ianharrigan
Copy link
Member

hmmm, that seems odd - i wonder if something has changed internally in lime or hxcpp or something... bear with me, ill try this end (i would have expected webp to not work, unless that is supported by openfl / lime?)

@ianharrigan
Copy link
Member

ianharrigan commented Apr 25, 2023

OK, so can repro with the webp, which i think is probably valid because im guessing it doesnt support webp... although the error seems a little odd... (ill look into it).

I cant repro with a png, i tried: https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png and it seemed fine... what url were you using?

Cheers,
Ian

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png

That png indeed works, others such as https://via.placeholder.com/600x400.png and https://filesamples.com/samples/image/png/sample_1280%C3%97853.png don't work

@ianharrigan
Copy link
Member

image

Seems fine this end... ill update all my libs, something must have changed? What versions of openfl, lime, haxe, etc are you running?

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

image

Seems fine this end... ill update all my libs, something must have changed? What versions of openfl, lime, haxe, etc are you running?

Can you share your code?
Versions:

  • Haxe: 4.3.0
  • OpenFL: 9.2.1
  • Lime: 8.0.1

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

Actually, after some more testing, it seems that in this case html5 is actually having an issue

@ianharrigan
Copy link
Member

ianharrigan commented Apr 25, 2023

right, that also makes sense i think the browser is preventing haxe (not haxeui) from making that http request becuase the requested resources has said (CORS):

Access to XMLHttpRequest at 'https://filesamples.com/samples/image/png/sample_1280%C3%97853.png' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'https://via.placeholder.com/600x400.png' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It may work if you deployed to a real domain rather than localhost (but probably not)

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

right, that also makes sense i think the browser is preventing haxe (not haxeui) from making that http request becuase the requested resources has said (CORS):

Access to XMLHttpRequest at 'https://filesamples.com/samples/image/png/sample_1280%C3%97853.png' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'https://via.placeholder.com/600x400.png' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It may work if you deployed to a real domain rather than localhost (but probably not)

That makes sense, is there any way to add a Access-Control-Allow-Origin header to the request?

@ianharrigan
Copy link
Member

well, Access-Control-Allow-Origin comes from the server, not the browser, so the short answer is nope, it aint gonna happen. Maybe the http server you actually want to get images for is under your control? In which case you should be fine.

@SKBotNL
Copy link
Author

SKBotNL commented Apr 25, 2023

well, Access-Control-Allow-Origin comes from the server, not the browser, so the short answer is nope, it aint gonna happen. Maybe the http server you actually want to get images for is under your control? In which case you should be fine.

You're right. Lucky that is indeed the case.

@SKBotNL SKBotNL changed the title Image with external resource errors on Windows WEBP image errors on Windows Apr 26, 2023
@SKBotNL
Copy link
Author

SKBotNL commented Apr 26, 2023

OpenFL's Loader does not seem to support WEBP, as you can see from this switch: https://github.com/openfl/openfl/blob/develop/src/openfl/display/Loader.hx#L434.
Should we create an issue in openfl/openfl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants