View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0031483||Documentation||[All Projects] General||Public||2019-11-07 14:54||2020-01-17 08:38|
|Reporter||Scott Dunbar||Assigned To||Mark Alexander|
|Priority||Medium||Severity||C - General||Reproducibility||100%|
|Target Version||2.3.0||Fixed in Version|
|Summary||0031483: 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 Reproduce||1. 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)
5. See that the call delayed by 2 frames after the surface_resize() reports the correct new value of 1920x1080. (alarm)
|Tags||No tags attached.|
html5_scaling.yyz (19,202 bytes)
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 = 1" sets an alarm to be "triggered at the start of the next frame" to avoid misunderstanding.
||See comment above|
||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.|