-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Support framerates higher than 250 for faster I/O event handling #230
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
haven't looked at the rest of this but we are not adding new blocks using argument reporters. "last key pressed" was a mistake that should've never happened. |
There's no way to detect screen refresh rate in original Scratch. And there's also no way to let an extension load in original Scratch. If we dont use argument reporters, we must find a new solution to indicate screen refresh rate so applications could work more efficiently. |
Signed-off-by: FurryR <[email protected]>
Signed-off-by: FurryR <[email protected]>
I hope you can reconsider this PR. I've already changed argument_reporter_string_number to sensing_current so it should not bring any historical issues. |
Sorry, it was a mistake. |
Resolves
See
Reason for Changes
.Proposed Changes
This Pull Request refactors (entire) frameLoop to allow meaningful framerates higher than 250. This is a experimental change, however it won't break anything.
Now framerates higher than 250 will use deprecated
setImmediate
(this is fine because it is polyfilled by https://www.npmjs.com/package/setimmediate) instead ofsetTimeout
to callvm.runtime._step
, allowing the engine to capture multipleDOM
events before screen drawing.The
vm.runtime.renderer.draw()
is now synchronized with screen refresh rate while interpolation still works.Newly added features:
vm.runtime.screenRefreshTime
Screen refresh time speculated from screen refresh rate, in milliseconds. Indicates time passed between two screen refreshments. Based on site isolation status, the resolution could be ~0.1ms or lower.
sensing_current
screen refresh time
(field valuerefreshtime
)Indicates screen refresh time (described above) in seconds. This is required for Scratch projects to detect when to draw, for example:
(The argument reporter is replaced with
sensing_current
now)If the program is running on a
60Hz
monitor with480 FPS
, it will run with 90 rendering frames (to avoid sudden frame dropping) and 480 logic frames.Reason for Changes
Consider this situation:
There are only 60 screen updates every second while
vm.runtime.renderer.draw()
is called 240 times, which means that 180 calls are unnecessary.They could do this by changing framerate, but it is impossible to set framerate (= I/O sample rate) higher than 250.
Test Coverage
N/A. This is basically browser stuff. However, all tests are passed and it works fine with pen & sprite projects.
Additional Information
It is recommended to squash merge this Pull Request.