WebXR - AR camera capture image

I’m trying to get a screenshot in an app using WebXR.
This is the code I have right now:

var texture = new pc.gfx.Texture(this.app.graphicsDevice);
var image = this.app.graphicsDevice.canvas.toDataURL('image/png');
    
    
  
    var img = new Image();
    img.onload = function () {
        texture.minFilter = pc.gfx.FILTER_LINEAR;
        texture.magFilter = pc.gfx.FILTER_LINEAR;
        texture.addressU = pc.gfx.ADDRESS_CLAMP_TO_EDGE;
        texture.addressV = pc.gfx.ADDRESS_CLAMP_TO_EDGE;
        texture.setSource(img);
    };
    
    img.src = image;
    
    texture.setSource( img );
    this.photoPanel.element.texture = texture;

So here’s the tricky part. This code works when I’m still not in AR mode, it takes a screenshot and renders into the texture successfully.
However, if I enter XR mode (with the device’s camera) and do the same thing, I only get a black texture.
Is it possible that “Preserve Drawing Buffer” is disabled while in AR mode somehow?