Jump to content

Timeout on PIXI.Texture.fromURL?


gomgom
 Share

Recommended Posts

Hi all,

I'm currently working on a web project, where I need to display a vast amount of markers on a map. I am using a package called leaflet-pixi-overlay, which lets one add a PIXI overlay on top of a leaflet map. I am facing a couple of issues, which I believe to be really newbies problems.

The first one is simply how does PIXI.Texture.fromURL handle bad url's? The specs say that " it does a better job of handling failed URLs more effectively". But if I give it a bad url, an await on the promise never returns. Is there an event I'm supposed to catch somewhere, do I need to define a timeout or something? Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

sure , you can embed your loader with a promise and you can add a event to loader error event.
Be sure is attach to your instance of loader if you use multiple loader.

resolve or reject your promise with your specifications.

app.loader.onError.add((e,ee)=>{
    console.log('e,',e,'ee',ee);
})

https://pixijs.download/dev/docs/PIXI.Loader.html

From documentation, its should also possible to catch errors inside loader.load((loader, resources) => {   event

 

You should also allowed to use promise and await for PIXI.Texture.fromURL, because doc say it return promise.

PIXI.Texture.fromURL('url').then( ()=>resolve() ).catch( ()=>reject() );

 

 

Edited by jonforum
Link to comment
Share on other sites

Thanks for your answer. I'm relying on the promise approach:

try {
  newTexture = await PIXI.Texture.fromURL(
    url,
    {
      resourceOptions: {
        width: spriteMaxSizePx,
      },
    },
  );
} catch (err) {
console.log(`Error, Failed loading texture from ${url}, err=${err}`);
 }

With this, I never trigger the catch if the url is bad (my async function just hangs).

Maybe I'm doing something really dumb javascript-wise (I started this language not so long ago), but I think I should get my log error message?

Edited by gomgom
Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...