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

Passing a Data URI to Texture constructor hangs Loader (and isLoaded() never returns true) #1543

Closed
thomergil opened this issue May 12, 2020 · 6 comments · Fixed by #1546
Closed
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior

Comments

@thomergil
Copy link

If I'm reading the Texture constructor correctly, it should be able to handle Data URI as path. However, this hangs the loader forever.


export const Images: { [key: string]: ex.Texture } = {
    failure: new ex.Texture(
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANwAAADcCAYAAAAbWs+BAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gIUARQAHY8+4wAAApBJREFUeNrt3cFqAjEUhlEjvv8rXz
    ),
};

const allResources = { ...Images };
export const loader = new ex.Loader();
loader.suppressPlayButton = true;

for (const res in allResources) {
    loader.addResource(allResources[res]);
}

game.start(loader).then(function () { /* */ }

Invoking .load() on a Texture object that was constructed with a Data URI never returns true for .isLoaded().

One thing that catches my attention in Texture's constructor is that it appears that:

            this._isLoaded = true;

...is called for path that is not a Data URI, but it is never called for a path that is a Data URI. See https://github.com/excaliburjs/Excalibur/blob/57e03f4d/src/engine/Resources/Texture.ts#L73

@thomergil thomergil changed the title Passing a DataURI to Texture constructor hangs Loader and never isLoaded() == true Passing a DataURI to Texture constructor hangs Loader (and isLoaded() never returns true) May 12, 2020
@thomergil thomergil changed the title Passing a DataURI to Texture constructor hangs Loader (and isLoaded() never returns true) Passing a Data URI to Texture constructor hangs Loader (and isLoaded() never returns true) May 12, 2020
@eonarheim eonarheim added the bug This issue describes undesirable, incorrect, or unexpected behavior label May 12, 2020
@eonarheim
Copy link
Member

Good find, that shouldn't happen

@thomergil
Copy link
Author

I believe the fix might be adding this._isLoaded = true; in the part of the constructor that deals with a Data URI path. (Though I don't have enough understanding of the code yet whether that will resolve the hanging Loader; I have to assume that something polls all resources until isLoaded() == true, though?)

@thomergil
Copy link
Author

My suggested fix does not, in fact, resolve the hanging loader problem.

@eonarheim
Copy link
Member

eonarheim commented May 13, 2020 via email

@thomergil
Copy link
Author

I think it's there: https://github.com/excaliburjs/Excalibur/blob/master/src/engine/Resources/Texture.ts#L64

@thomergil
Copy link
Author

Awesome.

eonarheim added a commit that referenced this issue May 17, 2020
Closes #1543

## Changes:

- Calls `complete()` callback on the super type that the loader listens too
- Adds a test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants