gomgom Posted September 24, 2020 Share Posted September 24, 2020 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! Quote Link to comment Share on other sites More sharing options...
jonforum Posted October 4, 2020 Share Posted October 4, 2020 (edited) 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 October 4, 2020 by jonforum Quote Link to comment Share on other sites More sharing options...
gomgom Posted October 5, 2020 Author Share Posted October 5, 2020 (edited) 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 October 5, 2020 by gomgom Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 5, 2020 Share Posted October 5, 2020 This API exists for 3 months, i believe there might be bugs, you have to debug it, or provide us example for reproduction. Quote Link to comment Share on other sites More sharing options...
jonforum Posted October 5, 2020 Share Posted October 5, 2020 all work fine on my side https://www.pixiplayground.com/#/edit/2hKyMDQglqpFHp31cqoCL if you start in js, this site is good to learn .https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch Quote Link to comment Share on other sites More sharing options...
a-c-sreedhar-reddy Posted May 18, 2021 Share Posted May 18, 2021 Hi @ivan.popelyshev here is an example for reproduction https://www.pixiplayground.com/#/edit/ODYvbxIipI6XGefVeOEws Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.