When a C2 game is placed in an iframe, the game receives double touch / tap events each time the user taps. This happens on mobile only, not on desktop.
Attach a Capx
https://static.gamezop.com/yashash/scir ... h-bug.capx
Description of Capx
Uses the touch and tap events to update a text view that displays the touch and tap counts. Uses no third party plugins.
Steps to Reproduce Bug
- Create a simple HTML file which has an iframe that runs localhost:50000 (assuming you are running C2 projects on port 50000 locally)
<iframe src="http://localhost:50000" width="100%" height="100%"></iframe>
- Host this file locally (say at port 8000)
- Open the given capx file, and run the project (each time you tap on the canvas, the touch and tap count should increase by 1)
- Open developer options (Ctrl + Shift + I on Chrome) and enter mobile mode. Run localhost:50000 again and tap on the page. The counts still increment by 1 on each touch / tap. If you tap fast, you'll see tap counts fall behind, but I could still live with that.
- Now run the iframe page while still in mobile mode (localhost:8000 in this example). This will open the game in an iframe. Tap on the page now and each time you tap, the count increases by 2.
When the game is run in an iframe, C2 receives 2 touch events for each time a user taps on the game page.
C2 should register only one touch for each time the user taps on the page. Games often always run within iframes (so that the parent page can have ad scripts / other games etc.).
Consider a very simple example - if I have a shooting game and the player has a total of 5 bullets, with one fired on any touch end. If the game is in an iframe, each user tap will exhaust 2 bullets, while it should exhaust 1.
Please note, the problem has to be reproduced in the mobile mode on each of these browsers.
- Chrome: YES. Version 64.0.3282.167 (Official Build) (64-bit)
- FireFox: YES. Version 59.0b11 (64-bit) - Developer Edition.
Here, you notice a very interesting problem. When the game is run in an iframe in the mobile mode, each touch end increases the touch count by 2, but the tap count only increases by 1. The given capx was saved with r253. If you run the same project with r237, you notice this same behavior on Chrome as well - tap count increases by 1 and touch counts increase by 2.
I've written to C2 Support email about this problem, but I never got a clear solution. For the longest time, I was using tap events (it has its own drawbacks, but there are a few maniacal workarounds) in my game instead of touch. But as you see, in the new release, even tap counts increase by 2 when the game is in an iframe. As a result, I can't update to the latest C2 builds.
- Internet Explorer: Sorry, but I honestly have no idea how to open mobile mode on this thing.
Operating System and Service Pack
Windows 10 Home, Version 1709, OS Build 16299.248
Construct 2 Version ID
237 and 253.