title: Loading PIXI textures, handling failures
body: <p>I'm working on a map project under React, using react-leaflet, and leaflet-pixi-overlay. Markers are implemented using the PIXI overlay (React 16.13.1, pixi.js 5.3.0, leaflet 1.6.0, leaflet-pixi-overlay 1.8.1).</p>
  <p>I am struggling a bit with the PIXI documentation. I would like to use this PIXI.Texture.fromURL method (<a href="http://pixijs.download/release/docs/PIXI.Texture.html#.fromURL" rel="nofollow noreferrer">http://pixijs.download/release/docs/PIXI.Texture.html#.fromURL</a>)</p>
  <p>However neither my VS Code environment, nor my compiled source can access this method.
  I am using instead PIXI.Texture.from(imageUrl), as well as PIXI.Texture.fromLoader(imageUrl). Both seem to work, but I don't get the difference between the two? The docs don't show these as being promises, yet they seem to work well with an async await?</p>
  <p>Then, when a load fails, I don't see how to tell that things went wrong. Actually what I don't see is how to tell that things went right!
  If I do:</p>
  <pre><code>    let failed = false;
      let newTexture;
      try {
        newTexture = await PIXI.Texture.from(url);
      } catch (err) {
        console.log(`FAILED loading texture from ${url}, err=${err}`);
        failed = true;
      }
      console.log(`valid=${texture.valid}`);
  </code></pre>
  <p>Then:</p>
  <ul>
  <li>texture.valid is always false, even when the texture loaded and displays just fine</li>
  <li>no error is ever thrown when the url points to nowhere</li>
  </ul>
  <p>Any pointers, is there a site with good (recent as of 2020) PIXI references? Am I missing something basic? Thanks.</p>
  <hr />
  <p><strong>Edit 07/06/2020:</strong></p>
  <p>Issues were largely due to both my IDE and webpack not 'seeing' that I had update pixi.js to 5.3.0, restart of both gave me access to Texture.fromURL.</p>
  <p>The Texture.from call is a synchronous one. My understanding is that by default, it will load a 'valid' texture of 1x1 px in case of failure. Texture.fromURL was added to provide an async solution, see <a href="https://github.com/pixijs/pixi.js/issues/6514" rel="nofollow noreferrer">https://github.com/pixijs/pixi.js/issues/6514</a></p>
  <p>Looks to me like Texture.fromURL still needs a bit of work, as it doesn't seem to ever return on a failed fetch (at least for relative paths, which is what I use). I see the same thing when using the following approach:</p>
  <pre><code>const texture = PIXI.Texture.from(url, {
    resourceOptions: { autoLoad: false }}
  );
  await texture.baseTexture.resource.load();
  </code></pre>
  <p>With a bad relative path, the load function never returns in my test environment.</p>