Error: null is not an object (evaluating 'b.acceleration.x')
First seen Feb 25, recently saw a spike that bumped in into the top errors
Error: null is not an object (evaluating 'b.acceleration.x')
at x (https://raw.githubusercontent.com/ampproject/amphtml/2003241513590/extensions/amp-delight-player/0.1/amp-delight-player.js:421)
at event (https://raw.githubusercontent.com/ampproject/amphtml/2003241513590/src/event-helper-listen.js:58)
It appears all occurrences are on iPhone on one domain: https://amp-focus-de.cdn.ampproject.org/c/s/amp.focus.de/politik/deutschland/hammer-and-dance-szenario-angestrebt-internes-papier-deutschland-steuert-im-kampf-gegen-corona-auf-suedkorea-strategie-zu_id_11819262.html?usqp=mq331AQDsAEg
Unclear if the issue is only on that domain, or just that that domain introduced something which triggers the bug, and has high enough traffic that it dominated the error report sampling.
/tryassign @xymw who added the player, might have insight /cc @ampproject/wg-ui-and-a11y
An invitation to join ampproject has been sent to @xymw. I will update this thread when the invitation is accepted.
The invitation to @xymw was accepted! I've assigned them to this issue.
Hi! It seems that on iOS Safari with the release of version 13.4 the DeviceMotionEvent doesn't include the acceleration property any longer. This is most likely a bug on Apple's end. What we can do is to guard against this. The player will then handle the missing motion information:
const payload = {
interval: event.interval,
timeStamp: event.timeStamp,
};
if (event.acceleration) {
payload.acceleration.x = event.acceleration.x;
payload.acceleration.y = event.acceleration.y;
payload.acceleration.z = event.acceleration.z;
}
if (event.accelerationIncludingGravity) {
payload.accelerationIncludingGravity.x = event.accelerationIncludingGravity.x;
payload.accelerationIncludingGravity.y = event.accelerationIncludingGravity.y;
payload.accelerationIncludingGravity.z = event.accelerationIncludingGravity.z;
}
if (event.rotationRate) {
payload.rotationRate.alpha = event.rotationRate.alpha;
payload.rotationRate.beta = event.rotationRate.beta;
payload.rotationRate.gamma = event.rotationRate.gamma;
}
this.sendCommand_(DelightEvent.WINDOW_DEVICEMOTION, payload);
Thanks for figuring this out and coming up with a patch so quickly!