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

Update _GameMaker.js #391

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Update _GameMaker.js #391

wants to merge 2 commits into from

Conversation

GINOFM
Copy link

@GINOFM GINOFM commented Oct 23, 2023

A possible solution to stuttering in mobile browser, mostly when the player touch the screen but not limited to that.

I develop multiplatform games (html5 web, Android and Windows); throughout the year I have been looking for a solution to the problem of micro lag or micro cuts when a game is played in a mobile browser, I have been using this solution with good results, now the games go really smooth on mobile and desktop.

The only problem I found is that the FPS counter (fps function) does not work correctly even if the game is running at a stable 60fps.

@DiasFranciscoA
Copy link
Contributor

@GINOFM, I've taken the time to review and test your proposed changes. Unfortunately, it appears that there's an issue where the frame tick is not advancing beyond the initial frame of execution. Could you please double-check to ensure your solution is compatible with the latest version of the runner? We're eager to incorporate your PR, especially if it resolves the freeze-on-touch problem we've been facing. Your efforts towards refining this fix are greatly appreciated.

// this might be best done after if(!Run_Paused) block,
// but then an exception would halt the game loop.
var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed;
var now = g_CurrentTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using g_CurrentTime instead of Date.now(); seems to be locking the runner to not go past the first frame of execution.

@GINOFM
Copy link
Author

GINOFM commented Feb 18, 2024

hello, I tested it again with the version "GameMaker-HTML5-2024.02.0-main", I realized that it works for me since I used it with projects already started, but in new projects it is necessary to add some sprites or a big image (at least 1024px*1024px), with that it avoids that it freezes at the beginning; it is not the ideal solution but it works, I have to continue investigating to what is due that error.

var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed;
var now = g_CurrentTime;
var delay = nextFrameAt - now;
if (delay < 0) {
delay = 0;
}
g_FrameStartTime +=delay;
if (delay <= 4) {
if (window.yyRequestAnimationFrame) {
window.yyRequestAnimationFrame(animate);
} else {
window.postMessage("yyRequestAnimationFrame", "*");
}

}
newfps++;

also I only used this code, and move the newfps from the previous statment.

a solution for the fps issues in mobile
@GINOFM GINOFM reopened this Feb 19, 2024
@DiasFranciscoA
Copy link
Contributor

A fix was merge on solving this issue already. It went into developer branch. Stutter should be reduced on inexistent, please consider verifying the developer branch.

@GINOFM
Copy link
Author

GINOFM commented Feb 19, 2024

Hi, I tested the developer branch, the issue is reduced but still persist

@GINOFM
Copy link
Author

GINOFM commented Feb 20, 2024

I tested it with the develop version, it is no longer necessary to add an image to make it work and it looks much more fluid on mobile.

@GINOFM
Copy link
Author

GINOFM commented Oct 4, 2024

Hello, I tested in the newest version of GM, and the performance in html5 in mobile is really bad, unplayable, I tested my code and still work

@TrunXGIT
Copy link

I can confirm that the issue with the short stutter on every screen touch is (still or again?) present in the current 2024.1100 Beta on Android when using Chrome. In Firefox it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants