Coder Social home page Coder Social logo

gamemaker-html5's People

Contributors

caroparo avatar diasfranciscoa avatar dragonitespam avatar iampremo avatar jackerley avatar jefvel avatar jonnorobson avatar jzavala-yyg avatar katsaii avatar kraifpatrik avatar lukebrownyoyogames avatar nkrapivin avatar opera-vdiachenko avatar pkraif avatar rowanfuture avatar rwkay avatar sidorakh avatar smithtom6304 avatar sp202 avatar stuckie avatar toad06 avatar toby-yoyo avatar trumdu avatar yellowafterlife avatar yoyo-danielc avatar yoyofritz avatar yyalansavage avatar yymrennie avatar ze0nni avatar zreedy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gamemaker-html5's Issues

_GameMaker.js GameMaker_Tick() : performance issues

(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.

Empty structs added to structs in debug mode (Chrome)

var struct = {
	foo : { this : 1 },
	bar : { this : 2 }
}

var names = variable_struct_get_names(struct);
for ( var i=0; i<array_length(names); i++ ){
	show_debug_message(names[i]);
}

Running this code in debug mode will produce empty struct references in the main struct.

issue

Games no longer work in older iOS Safari versions due to the nullish coalescing operator (??) and public field declarations

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; }

Audio Pitch Crash on Opera

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).

array_sort() broken on Google Chrome

Recreation:

var array = [32,24,46,2,9,4,573,0];
array_sort(array, function(a, b){
	return a > b;
});
show_debug_message(array);

The above code works on Windows & Firefox but not on Google Chrome:
Capture

Stopping the game for any Unhandled Rejection

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;
}

"event_perform" Crash

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.

Multitouch input positions (device>0) are sometimes wrong on mobile devices (device /iOS.js SetLocation issue)

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

yyCommandBuilder : performances issues on use of blocking getParameter calls

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

SDF for html5

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.

Sequences created in-runtime via sequence_create doesn't appear on screen

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.

crash on Android trying to open an Android app

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)

layer_sequence_create doesn't work for Sequence Object Structs

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.

yyNineSliceData performance issues

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.

Access to the feature "gamepad" is disallowed by permissions policy

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.

SyntaxError: Unexpected token '='. Expected an opening '(' before a method's parameter list.

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.

move_snap returns unexpected results with non-positive values

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)

function move_snap(_pInst,_hsnap,_vsnap)

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).

Font height is based on scalex of font.

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:

return this.max_glyph_height * this.scalex;

draw_text_bla() alignment in HTML5 is different to desktop export alignment?

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.

HTML5TestText

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.

instanceof(global) is undefined rather than "global" (as on native)

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.

Need mapping between released runtime and branch

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!

collision_rectangle is failing to register collisions.

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?

Attempting to call a built-in function from its index stored in an array, using self.array, causes a crash

(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

Changing entity depths to non integer values gradually degrades performance

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.

Bug: vertex_freeze does not return status code as documented

WebGL_vertex_freeze_RELEASE always returns undefined.

function WebGL_vertex_freeze_RELEASE(_buffer) {

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.

Issue with lerp function accuracy in HTML5 Project

Issue with lerp function in HTML5 gamemaker projects.
I seem to have issues with rounding and in like this example cant get image_xscale to ever reach target_scale.

IDE v2023.8.2.108 Runtime v2023.8.2.152
(yyz too big to add here)

image

`string_trim_end` does nothing

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)

In-Game: [HTML5] audio_resume_sound() can crash the game with "Failed to execute 'start' on 'AudioBufferSourceNode'"

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);
	}
}
  • Confirmed crash on latest public HTML5 runtime (December 15th 2023 commit in the develop branch)
  • Confirmed crash on latest Beta (2023.1100.0.450 / 2023.1100.0.459)
  • Can't trace back to what commit it worked, but I assure you it was working. I reviewed some other old projects and I did have a try/catch block around the resume logic on some, but I also tried using that and it still does not work - it actually does not catch the exception.

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:

audio issue html5.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.