yoyogames / gamemaker-html5 Goto Github PK
View Code? Open in Web Editor NEWGameMaker HTML5 runtime
License: Other
GameMaker HTML5 runtime
License: Other
(1) Line 2239:
// schedule next frame:
// this might be best done after if(!Run_Paused) block,
The next frame scheduling is indeed probably better done after the if(!Run_Paused) block.
(2)
Also, when there is positive delay (>0ms) but delay < minimum (<4ms), it seems to be better to set the delay to 4 instead of calling directly as the code does now. On some mobile devices (Pixel 3A XL), it can be observed (using chrome://inspect/#devices) that when ticks are well within the 60FPS range (16.8ms), sequential GameMaker_Tick()s are called without delays, causing "Partially presented frames" to occur.
The nullish coalescing operator (??) is not supported in iOS Safari versions older than 13.3: https://caniuse.com/mdn-javascript_operators_nullish_coalescing
Public field declarations are only supported since version 14.5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields#browser_compatibility
Both issues specifically crash games on startup on iPhone 6.
I think both features could use a polyfill to support older devices. The nullish coalescing operator can be replaced with a function like this:
function _NCO(a,b) { var _c; return (_c = a) !== null && _c !== void 0 ? _c : b; }
For Opera browsers, setting the pitch of an instance of a sound below 0.1 caused a crash (this might not be the specific value, but it was around there). As in, audio_sound_pitch(audio_play_sound(snd, 0, false), 0.01)
.
From post https://forum.gamemaker.io/index.php?threads/2023-8-release-thread.105622/post-636446: function part_type_sprite
causes error "Unhandled Exception - Uncaught ReferenceError: _y01 is not defined in file". There's most likely a typo in one of the variable names used by the function.
GameMaker stop when any unhandled exception occurs. Found the reason in the file _GameMaker.js
function yyUnhandledRejectionHandler( error )
{
var string = "Unhandled Rejection - " + error.message;
print( string );
//alert( string );
game_end(-2);
debugger;
return false;
}
window.addEventListener( "unhandledrejection", yyUnhandledRejectionHandler );
The game stop even if an unhandled exception appears in the Extension when the asynchronous function is running. Exception handling for asynchronous function added.
return payments.purchase(r)
.then((t) => {
return this.trigger("PaymentsPurchase", t), void window.focus();
})
.catch((e) => {
console.warn(e), this.trigger("PurchaseError"), window.focus();
});
I think the game needs to output an error message to the browser console, and not stop game.
function yyUnhandledRejectionHandler( error )
{
console.error("Unhandled Rejection - " + error.message);
return false;
}
Calling an instance's event on HTML5 versions crashes the game for step events and alarm events (but not draw events?). As in, event_perform(ev_alarm, 0)
or event_perform(ev_step, ev_step_end)
. I don't have access to HTML5 export as of the past couple days(?) so I can't test this issue further, but I experienced the issue within the past week.
When a room has an enabled and visible view, SetTouchLocation includes extra logic that overwrites eventX, eventY values from touchHandler, making them incorrect, unlike g_EventMouseX, g_EventMouseY that are unmodified for device 0.
The view in question has custom scaling logic, so it's not the same size as the application_surface or gui size.
I'm not sure whether it's safe to simply remove the pView.GetMouseX, pView.GetMouseY logic, but that's what works for me.
Edit: Also, the mobile exports always have multitouch controls working as intended.
Related scripts and functions:
functions/Function_YoYo.js : device_mouse_x_to_gui, device_mouse_y_to_gui
device/iOS.js : touchHandler(event)
device/iOS.js : yyTouchEvent.prototype.SetTouchLocation
Having README.md and CONTRIBUTING.md files would be beneficial for those who come across the repo from sources other than https://gamemaker.io/en/blog/html5-open-source.
The implementation doesn't match documentation nor previous expected behavior.
Doc
On a mobile browser (Pixel 3A XL, Chrome), I've observed WebGL performance issues in CMD_CLEARSCREEN, which relies on gl.getParameter(gl.DEPTH_WRITEMASK) and gl.getParameter(gl.COLOR_WRITEMASK) queries instead of cached values that the command builder should already know.
They are called even when surface_depth_disable(true) and gpu_set_zwriteenable(false) were set.
According to Morzilla's guide, these should be avoided in production code.
I've tried caching the values upon SetGLRenderState and CMD_SET_COLOUR_MASK, and the performance gains seem to be great.
Reference:
WebGL best practices
Hi, why in the current branch the SDF effect for font its not enabled?? In the 2023.08.0-main branch I can use the SDF effect in the web export without any error.
Custom made sequences are not visible on screen after adding them in a room with layer_create_sequence
. This happens because they don't have their m_channels
fully populated due to the incorrect gmlcahmmels
setter. It only adds one channel for each keyframe so for example in the position there's only x and no y and in the scale there's only xscale and no yscale, so that's why it's not visible I believe.
This is only applicable after resolving issue #297 because currently it's not possible to even create a sequence on a layer from sequence object struct.
I added a fix for that also to my previous pull request.
I was trying to have an app running in-browser and having it open another app on the Android and ran into a crash
--------- beginning of crash
09-14 13:36:00.953 14242 14266 E AndroidRuntime: FATAL EXCEPTION: GLThread 35
09-14 13:36:00.953 14242 14266 E AndroidRuntime: Process: com.company.game, PID: 14242
09-14 13:36:00.953 14242 14266 E AndroidRuntime: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
09-14 13:36:00.953 14242 14266 E AndroidRuntime: at com.yoyogames.runner.RunnerJNILib.Process(Native Method)
09-14 13:36:00.953 14242 14266 E AndroidRuntime: at com.company.game.DemoRenderer.onDrawFrame(DemoRenderer.java:500)
09-14 13:36:00.953 14242 14266 E AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
09-14 13:36:00.953 14242 14266 E AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
From post https://forum.gamemaker.io/index.php?threads/2023-8-release-thread.105622/post-636458: function part_particles_create
causes error "Unhandled Exception - Uncaught ReferenceError: _Rp is not defined in file". There's most likely a typo in one of the variable names used by the function.
Currently, it is only possible to create sequences in rooms from sequence ids.
layer_sequence_create(layer, x, y, seq_test); // working correctly
layer_sequence_create(layer, x, y, sequence_get(seq_test)); // not working correctly
If you try to spawn a sequence from sequence_get
or sequence_create
it will create the first sequence in the project instead. This is due to the call of yyGetInt32
inside layer_sequence_create
on the sequence_id
argument which always returns 0 for sequence object structs.
In other runtimes it works correctly and spawns sequences from both ids and sequence structs.
I implemented correct sequence creation that now accepts both indexes and sequence structs.
If a nine-sliced sprite is used multiple (N) times on a sprite asset layer (with different width,height dimensions), each element will cause the sprite's yyNineSliceCacheData to be re-generated, causing performance issues (N regenerations each frame).
This can be worked around by manually duplicating the asset element's sprites as well as their nineslice data on Room Start, and delete on Room End. However the issue is obscure and the workaround tedious.
How to run it?
Hello,
First of all, thank you for open sourcing this! Github Issues is much easier to use for bug reports, so I'm gonna try it out with one relatively frequent stack trace I see in Poki dashboard.
SecurityError: Failed to execute 'getGamepads' on 'Navigator': Access to the feature "gamepad" is disallowed by permissions policy.
Happens on Chrome, Opera and Edge.
I assume/hope (not confirmed) this doesn't cause a full game crash, but maybe could be cleaned up.
Hello,
Would like to report another crash which happens in newer Safari browsers and only appeared in latest GameMaker runtimes (2022.03 is the last "safe" one as far as I know). It is present in LTS too.
SyntaxError: Unexpected token '='. Expected an opening '(' before a method's parameter list.
at ? [html5game/BaconMayDie.js:6926:]
Unfortunately, I cannot provide any more details, because this is all what stack trace shows.
Here's a StackOverflow thread talking about what seems to be this exact error:
https://stackoverflow.com/questions/60026651/
Hope someone figures out where to look for this issue.
One of the uses for move_snap() is calling it with values that match the current speed of an given object in order to ensure it always gets aligned on a grid. If move_snap() is called with a value higher than the actual speed component for that instance then it would just prevent it from moving. It also work with negative values and won't do anything if set to 0 on both arguments. (Tested on Windows and Android exports)
On HTML5 export, however, if move_snap is not handled manually beforehand (i.e.: if _myspeed>0 {move_snap(_myspeed,_myspeed)}
) it will attempt to divide by zero, which crashes the game.
Unhandled Exception - Uncaught { message : "Cannot apply sqrt to negative number.", longMessage : "Cannot apply sqrt to negative number.", stacktrace : [ "function _Ti2("Cannot apply sqrt to negative number.")
","function sqrt(NaN)
","function _mJ4([unknown])
","function _oJ4([unknown], [unknown])
","function _wJ4([instance], [instance])
","function([instance], [unknown])
","function([instance])
","function _pM2([instance], 100004, [unknown], -4, [unknown])
","function _lF2([instance], NaN, NaN, [unknown], [undefined])
","function _hF2([instance], NaN, NaN, [unknown])
","function _Uf1([instance], 0, 0, [unknown])
","function _BD1([instance], [instance])
","function _v2([instance], [instance])
","function(769, 0, [instance], [instance])
","function(769, 0, [instance], [instance])
","function(769, 0)
","function _rm5()
","function _Yl5()
","function _pl5(4391.76)
" ], script : "", line : -1 } in file http://127.0.0.1:51264/html5maddierush/BLANK%20GAME_2.js?cachebust=1627255119 at line 2493
BLANK%20GAME_2.js?cachebust=1627255119:2491 ###game_end###-1
BLANK%20GAME_2.js?cachebust=1627255119:2493 Uncaught _Dw2_F5: true_Jw2: "Cannot apply sqrt to negative number."_Kw2: (19) ['function _Ti2("Cannot apply sqrt to negative number.")\n', 'function sqrt(NaN)\n', 'function _mJ4([unknown])\n', 'function _oJ4([unknown], [unknown])\n', 'function _wJ4([instance], [instance])\n', 'function([instance], [unknown])\n', 'function([instance])\n', 'function _pM2([instance], 100004, [unknown], -4, [unknown])\n', 'function _lF2([instance], NaN, NaN, [unknown], [undefined])\n', 'function _hF2([instance], NaN, NaN, [unknown])\n', 'function _Uf1([instance], 0, 0, [unknown])\n', 'function _BD1([instance], [instance])\n', 'function _v2([instance], [instance])\n', 'function(769, 0, [instance], [instance])\n', 'function(769, 0, [instance], [instance])\n', 'function(769, 0)\n', 'function _rm5()\n', 'function _Yl5()\n', 'function _pl5(4391.76)\n']_Lw2: ""_Mw2: -1__y: "Cannot apply sqrt to negative number."[[Prototype]]: Object
BLANK%20GAME_2.js?cachebust=1627255119:2491 Unhandled Exception - Uncaught TypeError: Failed to construct 'AudioBufferSourceNode': parameter 1 is not of type 'BaseAudioContext'. in file http://127.0.0.1:51264/html5maddierush/BLANK%20GAME_2.js?cachebust=1627255119 at line 2703
also when using negative numbers, it still works, but seems to returns non-integer values despite being called with a negative integer, which resulted into a blurry screen (it could certainly have something to do with the way surfaces are coded in this project in particular, which I can try to reproduce if necessary).
I'm not sure if internal value of yyFont
named scalex
can be different than 1
- (as we don't have function to change font scalex - maybe it's for some future usage ?), but still, returning height based on xscale sounds like bug, and rather scaley
should be used here:
GameMaker-HTML5/scripts/yyFont.js
Line 421 in 82718d0
I have a simple test yyz for you guys to see. It seems when placing text via draw_text functions the position is different when exported to HTML5. If I align things for desktop they work and are where I placed them but the text in html5 is way off.
Download the yyz. Export to desktop target and check where the text is in the white square. Now export to html5 and you will see the text alignment is completely off.
Snippet:
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
show_debug_message("instanceof={0} typeof={1}", instanceof(self), typeof(self));
Windows:
instanceof=global typeof=struct
HTML5:
instanceof=undefined typeof=struct
Adding
this.__type = "global";
to yyGameGlobals
constructor works.
I've been experiencing a bug on surface draw_clear_alpha which caused HTML5 to render incorrectly.
With branch master-feb-23 I cannot reproduce it, but I don't know how to find a matching branch to runtime v2023.2.1.90 where I see the issue.
Could you please add some guides to the README file? Thanks!
I have this code:
if ( collision_rectangle(x -16, y + 4, x + 16, y + 4, oPlatParent, false, true) ) { blah when collision occurs }
Basically, I have a player sprite which is 64x64 pixels. I have a platform which is 64x64 pixels. The platform is parented to oPlatParent. When the player is falling it should collide with the platform and register a collision, which it does on desktop platforms) but HTML5 seems to ignore the collision completely.
It was confirmed as a bug by YoYo bug support. I was wondering if anyone can check the collision_blah() functions and see if anything is wrong?
(Sorry for the somewhat involved title)
Description
This is a fairly specific bug that occurs when one has a function index stored in an array (for example, this happens in my UI library, gooey, where the user specifies callback functions that get called whenever a certain interaction event happens, such as a left mouse released event). When said array is then referenced using self
and then called in the same line, it throws an error.
The built-in function can have 0 or more arguments (with 1 or more arguments, one would obviously need to specify them in the function calls below):
self.func = window_center;
Code:
self.arr = [];
array_push(self.arr, self.func);
arr[0](); // works
self.arr[0](); // Error: Unable to get object for index XXXXX
It's noteworthy that assigning the (index) value contained in the array to a local variable and then calling the corresponding function, works:
var _arr = self.arr[0];
_arr(); // works
Also, this behavior does not happen when the index is stored inside an instance or local variable instead of an array:
func() // works
self.func(); // works
Lastly, none of this happens either when using a custom function:
function test() {
show_debug_message("TEST at {0}", current_time);
}
self.func = test;
self.arr = [];
array_push(self.arr, self.func);
arr[0](); // works
self.arr[0](); // works as well!
The code shown is included in the YYZ attached below for easy replicability
Function calling bug with self.zip
My game was getting worse performance the longer it ran, even though there were less than 40 active instances. After some troubleshooting, I noticed it had to do with the depth
of instances. I changed it based on their y
coordinate, going from 0 to 100.
It appears that it'll create pools for every unique depth, but then not remove them once the instance depth is changed or the instance is destroyed.
https://github.com/YoYoGames/GameMaker-HTML5/blob/develop/scripts/yyRoom.js#L3707
The pool list here kept growing every frame, to a size over 8000, at which point the game had ground to a halt.
However, if I made sure the depth was set to a rounded number instead of floating point between 0 and 100, the pool length was kept in check.
I'm not sure whether or not this is working as intended, I'm suspecting not. Either the depth should be ensured to be a rounded value, or make sure that the pool is cleaned of empty values.
WebGL_vertex_freeze_RELEASE always returns undefined.
GameMaker-HTML5/scripts/yyBufferVertex.js
Line 353 in c49c594
This behavior is different from Windows platform's and what the documentation described.
https://manual-en.yoyogames.com/#t=GameMaker_Language%2FGML_Reference%2FDrawing%2FPrimitives%2Fvertex_freeze.htm
Also: freezing the same vbuffer multiple times seems to cause issues so the vbuff cannot be rendered.
string_trim_end does nothing
test code:
var _str = string_format(1, 100, 10)
var _str = string_trim_end(_str, ["0"]);
var _str = string_trim_end(_str, ["."]);
var _str = string_trim_start(_str, [" "]);
show_debug_message(_str)
When trying to pause and then resume a sound, the HTML5 runner crashes with the following error message:
Unhandled Exception - Uncaught TypeError: Failed to execute 'start' on 'AudioBufferSourceNode': The provided double value is non-finite. in file XXX at line YYY
I'm attaching a sample barebones project, but the code I'm using is straightforward:
if (keyboard_check_pressed(vk_space)) {
self.music = !self.music;
if (self.music) {
if (audio_is_paused(snd_Music)) audio_resume_sound(snd_Music);
else audio_play_sound(snd_Music, 1, true);
}
else {
if (audio_is_playing(snd_Music)) audio_pause_sound(snd_Music);
}
}
develop
branch)Just for kicks, I added a try/catch block directly on the Function_Sound.js
file of the HTML5 runner, on line 425:
Was:
this.pbuffersource.start(0, startOffset);
After the test:
try {
this.pbuffersource.start(0, startOffset);
}
catch (exception) {
this.pbuffersource.start(0, 0);
}
And this prevents the crash (as startOffset
seems to be NaN
and hence the aforementioned error), although it does not resume the sound obviously since I'm using 0 as the new startOffset
on the catch
block it restarts it.
Example project:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.