View Issue Details

IDProjectCategoryView StatusLast Update
0031483Documentation[All Projects] GeneralPublic2020-07-13 14:44
ReporterScott DunbarAssigned ToMark Alexander 
PriorityMediumSeverityC - GeneralReproducibility100%
Status ResolvedResolutionReopened 
Product Version2.2.4 
Target Version2.3.0Fixed in Version2.3.0 
Summary0031483: Functions: surface_get_width/height functions do not return correct values for resized surface until after 2 frames
 surface_get_width and surface_get_height do not return the correct value after resizing a surface unless you wait for 2 frames

Steps To Reproduce1. Import attached project
2. Run the project using the Windows export
3. Note the output into the Console Log
4. See that the call delayed by 1 frame after the surface_resize() reports an incorrect value of 640x360. (alarm[0])
5. See that the call delayed by 2 frames after the surface_resize() reports the correct new value of 1920x1080. (alarm[1])
TagsNo tags attached.


Scott Dunbar

2019-11-07 14:54


html5_scaling.yyz (19,202 bytes)

Luke Brown

2019-11-22 11:08

Developer   ~0065144

After looking into this I'm not sure that this is an issue and more of a missing clarification within the documentation. The alarm timers tick down each frame, and fire when they reach 0. the check for whether or not the timer is 0 occurs directly after the decrement on both the CPP and HTML5 runners and this seems to be intentional. If an alarm is set to a value of 1, its value is decremented at the start of the 1st frame and then subsequently called.
The alarms are handled early in the loop, before anything else is updated or rendered that frame, meaning that the value returned by surface_get_width and surface_get_height will be the old value (since the application surface isn't updated until the room is drawn, after this alarm has triggered)

Moving the alarm handling to the end of the main game loop should fix this issue (since the room will have been rendered) but some people may rely on this functionality to affect change pre-render.

Alternatively, we could simply change "surface_get_width" and "surface_get_height" to return the pending surface size even if the surface has not yet been updated, but this contradicts the current documentation: "NOTE: If you are resizing the application surface, these changes will not be registered until the start of the next draw frame, meaning that calling the surface_get_width() or surface_get_height() functions in the same event or step will return the previous values."

I recommend that we simply update the documentation for alarms to clarify that "alarm[0] = 1" sets an alarm to be "triggered at the start of the next frame" to avoid misunderstanding.

Luke Brown

2019-12-02 09:19

Developer   ~0065185

See comment above

Mark Alexander

2020-01-17 08:38

Developer   ~0065302

The page on alarms already explains the behaviour of setting the alarm to 1 and when the alarm is run in the step order. However I have added a note into the surface_get_width/height functions (surface resize already mentions this) to mention that when applied to the application surface the values will need a couple of frames to be updated correctly.