How to make snapshot from another canvas

There are 2 canvases on page:

  1. with Phaser game attached
  2. another controlled by external scripts

I need to capture image from second canvas and put as sprite in first one.

This code perfectly works with Phaser 2.6

this.sprite.loadTexture(PIXI.Texture.fromCanvas(secondCanvasEl, PIXI.scaleModes.DEFAULT));
            

Any suggestions how to do that with Phaser v3.55 ?

const canvasTexture = this.textures.addCanvas('secondCanvas', secondCanvasEl);

this.add.image(x, y, canvasTexture);

@samme It will fails if second canvas using webgl. CanvasTexture doesn’t support:

CanvasTexture (manager, key, source, width, height)
...
this.context = this.canvas.getContext('2d');

How to grab image from webgl canvas ?

Phaser.Renderer.Snapshot.WebGL(secondCanvasEl, {
  callback: (image) => {
      this.textures.addImage('secondCanvas', image);

      this.add.image(x, y, 'secondCanvas');
  },
});