aframe: (master) Touching Daydream trackpad causes "TypeError cannot read property 'length' of undefined"
Description:
Touching Daydream touchpad causes TypeError cannot read property 'length' of undefined
. Because of this TypeError, I also seem not to get axismove
or trackpadmoved
events.
This is apparently a bug that @dmarcos is familiar with because I was able to find a fix he landed to try to work around it. I gather the empty touches array was added in https://github.com/aframevr/aframe/pull/2537 to avoid this problem, but somehow touches
doesn’t seem to make it on to the event? Here is the exact content of the touchstart
event fired from the Daydream trackpad (captured in Chrome remote devtools):
CustomEvent {isTrusted: false, detail: Object, type: "touchstart", target: a-entity, currentTarget: Window…}
bubbles: true
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
detail: Object
eventPhase: 0
isTrusted: false
path: Array(6)
returnValue: true
srcElement: a-entity
target: a-entity
timeStamp: 128821.66500000002
type: "touchstart"
__proto__: CustomEvent
Changing https://github.com/aframevr/webvr-polyfill/blob/master/src/touch-panner.js#L48 to read
TouchPanner.prototype.onTouchStart_ = function(e) {
if (e.touches) {
// Only respond if there is exactly one touch.
if (e.touches.length != 1) {
return;
}
this.rotateStart.set(e.touches[0].pageX, e.touches[0].pageY);
this.isTouching = true;
}
};
does solve the problem. After vendoring aframe and hacking that in, I get no more errors, and axismove
and touchmoved
events all work.
- A-Frame Version: master
- Platform / Device: Chrome Canary / Pixel XL/ Daydream Controller
- Reproducible Code Snippet or URL: any time Daydream Controller is connected
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (11 by maintainers)
Commits related to this issue
- Check for touches property before deep referencing Fixes TypeError when touching Daydream trackpad caused by the fact that Daydream controller creates an event object without a `touches` property. S... — committed to gordonbrander/webvr-polyfill by gordonbrander 7 years ago
- Check for touches property before deep referencing Fixes TypeError when touching Daydream trackpad caused by the fact that Daydream controller creates an event object without a `touches` property. S... — committed to gordonbrander/webvr-polyfill by gordonbrander 7 years ago
- Check for touches property before deep referencing Fixes TypeError when touching Daydream trackpad caused by the fact that Daydream controller creates an event object without a `touches` property. S... — committed to immersive-web/webvr-polyfill by gordonbrander 7 years ago
ok, closing my aframevr polyfill PR as well so you can do yours, thanks welcome aboard @gordonbrander !