title: Uncaught TypeError: Cannot read property 'naturalWidth' of null - FabricJs - preview a video in Fabric.js via loadFromJSON
body: <p>There is one issue I am facing while trying to preview video on a fabric.js canvas.</p>
  <p><strong>FabricJS Version Tried: 4.0.0-beta.8 And 3.6.3 same error in both</strong></p>
  <p>It gives error saying</p>
  <pre><code>Uncaught TypeError: Cannot read property 'naturalWidth' of null                          :fabric.js:20490
  </code></pre>
  <p>Code for how I am adding video to canvas:</p>
  <pre><code>let objects = slideData.getObjects();
  for (var i = 0; i &lt; objects.length; i++) {
      if (objects[i].hasOwnProperty('videoUrl')) {
          var videoElement = createVideoElement(objects[i]['videoUrl']); //this function returns a video element
          var video = new fabric.Image(videoElement, {left: objects[i]['left'], top: objects[i]['top'], isBackgroundVideo: true});
          slideData.add(video);//adding video to canvas.
          video.sendBackwards();//setting video to be on the back so I can show text in front of it
          console.log(slideData);
      }
  }
  </code></pre>
  <p>Code for how I am trying to preview video on canvas:</p>
  <pre><code>let jsonData = JSON.stringify(slideData.toObject(propertiesToSave)); //this is an array of properties which we want to save which includes isBackgroundVideo: true
  slideData.loadFromJSON(jsonData, slideData.renderAll.bind(slideData), function(o, object) { //loading saved canvas data from JSON
      object.set('selectable', false);
      object.set('cursorHover', 'default');
      let objects = slideData.getObjects();
      for (var i = 0; i &lt; objects.length; i++) {
          if (objects[i].hasOwnProperty('isBackgroundVideo')) {
              objects[i].getElement().play();
              fabric.util.requestAnimFrame(function render() {
                  slideData.renderAll();
                  fabric.util.requestAnimFrame(render);
              });
          }
      }
  });
  </code></pre>
  <p>But when i execute this code then fabric.js gives error.</p>
  <pre><code>Uncaught TypeError: Cannot read property 'naturalWidth' of null                          :fabric.js:20490
  </code></pre>
  <p>I tried most solutions but it just does not work. I am not sure what is wrong here. If I am doing something wrong or this is just a bug in fabric.js</p>
  <p>If you guys need more code then I can provide just comment what you need. Thanks</p>