Got an error when I create a new touch device under Chrome

As mentioned in the title, when I want to migrate the ’augmented’ script in the ‘iPhone6’ project to my own project, the ‘augmented’ script creates a new canvas, covers the main canvas of playcanvas, and touch events become unavailable.

Augmented.prototype.initialize = function () {
    var app =;
    this.canvas = document.createElement('canvas');
    this.canvas.width = app.graphicsDevice.width;
    this.canvas.height = app.graphicsDevice.height; = 'absolute'; = '0px'; = '0px';
    this.ctx = this.canvas.getContext('2d'); = app.root.findByName('camera');

So to solve this, I created a new touch device based on ‘window’ to re-enable touch

TouchTest.prototype.initialize = function() {
    var touch = new pc.TouchDevice(window); = touch;
    if (touch) {
        touch.on(pc.EVENT_TOUCHSTART, this.onTouchStart, this);
        touch.on(pc.EVENT_TOUCHMOVE, this.onTouchMove, this);
        touch.on(pc.EVENT_TOUCHEND, this.onTouchEnd, this);
        touch.on(pc.EVENT_TOUCHCANCEL, this.onTouchCancel, this);

However, when I test it in chrome, an error appears (but it seems that the game itself is running well)

Any good suggestions for solving this problem?

Here is the link to my testing project

Hi @kprimo,

I think this has been solved for mouse input, I wasn’t aware it happens for touch input. Maybe it happens here because you are emulating touch events in the browser, though I am not certain.

Try logging this issue on the engine repo, in case there is a fix about it in the engine side. There was an issue about it in the past:

So nice of you to let me know this. I’ll try to push an issue on github.