Closed mikeks closed 5 years ago
Can you show the output of game.debug.inputInfo(…)
and game.debug.pointer(…)
while the problem is showing? See https://codepen.io/samme/pen/gKqgbB for example.
You can try
this.input.mouse.stopOnGameOut = true;
I could reproduce this: https://codepen.io/samme/details/YMdQvB.
Next release will fix this but you’ll need to turn on input.mouse.stopOnGameOut
.
Using
this.input.mouse.stopOnGameOut = true;
does NOT help. This is because the events _onMSPointerOut don't have event.identifier property. As result pointer
is null:
var pointer = this.input.getPointerFromIdentifier(event.identifier);
And pointer.stop
never be called:
if (pointer)
{
pointer.stop(event);
}
For now I'm using the following workaround for the problem:
game.input.mouse.mouseOutCallback = function (event) {
console.log('Mouse out callback: ' + event);
if (game.input.pointer1.active && game.input.pointer2.active) {
console.log('Mouse out callback - stop pointers.');
game.input.pointer1.stop(event);
game.input.pointer2.stop(event);
}
};
Initially I didn't have the if
above, but this lead to sporadic scrolls in my game. After adding if
the problem seems gone.
I understand, that’s why I labelled it a bug. The fix is in 6551c8c and stopOnGameOut
will work as desired in the next release.
Sounds great! Hope to see the new release soon. :)
Hello,
I reporting a possible bug. I consider adding it to GitHub, but first I want to ask you opinion. Thank you for consideration.
I use Phaser CE 2.12.0 + Cardova Android. Testing on Android 8 (real device).
The game sometimes stops receiving any touch events. Nothing is touchable, although all the rest of the app (animation, etc) continue working. The problem resolved after collapse/restore the app.
After digging into Phaser source code, I find out that initial events _onMSPointerDown and _onMSPointerUp continue dispatching fine, but it never get propagated to my code. I was able to figure out the reason.
It seems that pointer up event sometimes get missed. If this happens, the game stops receiving any subsequent touch events.
The sequence is the following:
The game receiving _onMSPointerDown event Pointer locks in active state. The event.identifier stored in pointer1.identifier. The up event with the same identifier lost (probably due of processor load) Any further pointer down events ignored because pointer is in active state (it’s awaiting for up event) Any further pointer up events also ignored because new event identifier doesn’t match the stored one. All touch events locked now. Source for #4: Line 39558: if (!this.pointer1.active) <-- this now never true (the same for pointer2)
Source for #5: Line 39634: if (this.pointer1.active && this.pointer1.identifier === event.identifier) <-- identifiers doesn’t match, the touch never stops (the same for pointer2)
The problem is reproducible, but random. Happens more often when device is slower or debugger attached. I want to emphasis that problem happens on real device testing in release version without any debugger attached. The debugger just make the problem much worse and easier to reproduce.
UPDATE
After some digging more, I find out that instead of _onMSPointerUp I’m getting _onMSPointerOut. I found the following solution (a hack), which seems to works for now, but more testing is coming up:
game.input.mouse.mouseOutCallback = function (event) { console.log('Mouse out callback: ’ + event); game.input.pointer1.stop(event); game.input.pointer2.stop(event); };
This was initially posted in Forum here: https://phaser.discourse.group/t/game-stops-receiving-any-touch-events/2208 Thanks to
Thank you, Mike