Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key inputs are randomly lost and non-responsive in web export when hosted in an iframe #55248

Closed
jordo opened this issue Nov 23, 2021 · 8 comments · Fixed by #55342
Closed

Key inputs are randomly lost and non-responsive in web export when hosted in an iframe #55248

jordo opened this issue Nov 23, 2021 · 8 comments · Fixed by #55342

Comments

@jordo
Copy link
Contributor

jordo commented Nov 23, 2021

Godot version

3.4

System information

Firefox + Chrome, all OSs

Issue description

We host our web builds on various web portal sites. We experience (seemingly random) times where keyboard inputs from the <canvas> are not passed through to godot engine. All keyboard input is just lost, even though the game's canvas is still in focus. Mouse cursor and click events are fine, it is just related to keyboard input.

Steps to reproduce

This is incredibly hard to reproduce, as it is quite random, and requires a lot of setup... But export a 3.4 project to web, and host exported game within an iframe of another site.

This issue has only come up after upgraded to v 3.4, it seems this issue could be somewhat related to the refactor of js input here: b7ac3c1

Minimal reproduction project

No response

@jordo
Copy link
Contributor Author

jordo commented Nov 23, 2021

When our site gets into this state, I can confirm this line of code does NOT run (breakpoint on line 12296 does not hit):

image

When this breakpoint does not hit for a key press, regular mouse and cursor events run fine.

@jordo
Copy link
Contributor Author

jordo commented Nov 23, 2021

OK, so I can confirm how to reliably reproduce the issue (at least on chrome). When the game is hosted in an iframe, if you click outside the canvas/iframe, then click back in, keyboard inputs will cease.

@jordo
Copy link
Contributor Author

jordo commented Nov 23, 2021

I think this is probably related to this removal:

b7ac3c1#diff-44731e0168fe89a03ed7f77c76c86beaf84fdcb1097c763e7f4eee3a8c540cf8L371-L373

If I'm reading that correctly, previously we were explicitly focusing the canvas (for iframe) on every mouse button event?

@Chaosus
Copy link
Member

Chaosus commented Nov 23, 2021

cc @Faless

@jordo
Copy link
Contributor Author

jordo commented Nov 23, 2021

I can confirm that the removal of this b7ac3c1#diff-44731e0168fe89a03ed7f77c76c86beaf84fdcb1097c763e7f4eee3a8c540cf8L371-L373 was the regression. Putting this back in fixed our issues. It now again re-focusses the canvas on mouse event in an iframe.

@Faless
Copy link
Collaborator

Faless commented Nov 23, 2021

Duplicate of #55017, already fixed via #55111

@jordo
Copy link
Contributor Author

jordo commented Nov 25, 2021

This fix doesn't appear to work in firefox 95, but I can confirm it does work in chrome 96.

Can confirm that putting this back into the cpp side fixes the issue on firefox as well as chrome.

@Faless
Copy link
Collaborator

Faless commented Nov 26, 2021

This fix doesn't appear to work in firefox 95, but I can confirm it does work in chrome 96.

Thanks a lot for investigating this, should be fixed via #55342 .

@akien-mga akien-mga added this to the 3.5 milestone Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants