Cannot read property ‘_textureAtlas’ of undefined

Solution for Cannot read property ‘_textureAtlas’ of undefined
is Given Below:

When I use Cesium’s Clustering API, the official demo address:

https://sandcastle.cesium.com/index.html?src=Clustering.html

Then when I tried to improve the code, I got an error saying Cannot read Property '_textureAtlas' of undefined when I did a quick aggregation with the mouse zoom

I created a custom canvas in the code as the aggregate icon

function getClusterCanvas (length) {
  return new Promise((resolve, reject) => {
    let borderImg = new Image(),
      photoImg = new Image(),
      canvas = document.createElement('canvas'),
      ctx = canvas.getContext('2d')
    canvas.height = 50
    canvas.width = 50

    borderImg.src = require('@/assets/img/cesium/juhekuang.png')
    borderImg.crossOrigin = 'Anonymous'

    borderImg.onload = () => {
      ctx.drawImage(borderImg, 0, 0, 50, 50)
      photoImg.src = require('@/assets/img/cesium/typeP.png')
      photoImg.crossOrigin = 'Anonymous'
      photoImg.onload = (e) => {
        ctx.drawImage(photoImg, 15, 7.5, 20, 20)
        ctx.fillStyle="#23F5F3"
        ctx.fillText(`${length}人`, 18, 40)
        ctx.textAlign = 'center'
        resolve(canvas)
      }

      photoImg.onerror = (err) => {
        console.warn(err)
        reject(err)
      }
    }

    borderImg.onerror = (err) => {
      console.warn('border loading failed', err)
      reject(err)
    }
  })
}

And then I call it like this

let removeListener
// custom cluster
function customStyle (dataSource) {
  if (Cesium.defined(removeListener)) {
    removeListener()
    removeListener = undefined
  } else {
    removeListener = dataSource.clustering.clusterEvent.addEventListener(
      function (clusteredEntities, cluster) {
        cluster.label.show = false
        cluster.billboard.show = true
        cluster.billboard.id = cluster.label.id
        cluster.billboard.verticalOrigin =
          Cesium.VerticalOrigin.BOTTOM
        getClusterCanvas(clusteredEntities.length).then(res => {
          // cluster.billboard.image = res
          cluster.billboard.setImage('myImage', res)
        }).catch(err => {
          console.log('draw canvas failed', err)
        })
      }
    )
  }

  // force a re-cluster with the new styling
  var pixelRange = dataSource.clustering.pixelRange
  dataSource.clustering.pixelRange = 0
  dataSource.clustering.pixelRange = pixelRange
}

I used the canvas returned from resolve(), and the icon was successfully drawn on the page. However, as mentioned above, when I zoom in quickly, I get an error with the title. When I try not to use a custom canvas, I don’t get an error. Then I will position location to the getClusterCanvas this function and cluster.billboard.setImage('myImage', res) this line, But I don’t know how to deal with him, okay.

Finally, this is where the cesium source code reports an error
enter image description here