⇠ More posts

Defold release 1.3.1

By Björn Ritzl on Apr 05, 2022

Tagged as: Release notes


Improved timestep support

The biggest change this release is the improved support for the different timesteps between the game update loop and the physics update loop.

The goal is to have the game using vsync, and use the delta time between the display refreshes as the dt for the game loop. This will fix the issues we’ve seen with game running on displays with variable frame rates (or rates > 60hz).

The display.update_frequency (default is 0) variable has changed somewhat, and is only limiting the frame rate if it’s lower than the current refresh rate of the display. E.g. it can be useful to limit the frequency to something low (like 30) to simulate the behavior of for instance a KaiOS device.

The fixed physics update is off by default, in order to stay compatible with the old behavior.

These are the relevant settings:

  • engine.fixed_update_frequency
    • an integer setting in Hz
    • Default is 60
    • 0 means it’s disabled
    • We recommend e.g. 30 or 60 Hz
    • Corresponds to the script life cycle function fixed_update(self, dt)
  • physics.use_fixed_timestep
    • boolean
    • 0 (false) is default
    • 0 means variable frame rate (default)
    • We recommend using 1 for new projects
  • display.update_frequency (integer)
    • an integer setting in Hz
    • 0 means variable frame rate (default)
    • > 0 means fixed frame rate. Capped at runtime towards the actual frame rate. I.e. you cannot update the game loop twice in an engine frame.
    • Fixed time steps may be used to simulate slower devices, or throttle the performance at runtime. E.g. set to 30 to simulate the frame rate of KaiOS.
  • display.swap_interval
    • An integer setting that sets the OpenGL swap interval
    • (doesn’t work with Vulkan)
    • 0 disables vsync
    • Default is 1
  • display.vsync (DEPRECATED)
    • boolean
    • If set to false, forces a display.swap_interval = 0
    • Use the sys.set_update_frequency(hz) 2 to control the “display.update_frequency” at runtime.

We’ve added a fixed_update(self, dt) life cycle function to the game object scripts. When using fixed timesteps for the physics, this is where you’ll want to add the forces to your game objects, in order to keep in sync with the physics updates.

Frustum culling

We’ve added support for frustum culling. In this initial version of the feature, it’s only used for sprites. Expected benefits are reduced vertex buffer sizes (saving GPU bandwidth), and reduced number of draw calls (depending on projects).

Frustum culling is enabled by default in the default.render_script. If you have a custom render script, you need to create a frustum matrix, and pass it into your render.draw() calls.

Release notes

Engine

NEW: Added frustum culling to default render script (#6456)

In this initial version of the feature, it’s only used for sprites. Expected benefits are reduced vertex buffer sizes (saving GPU bandwidth), and reduced number of draw calls (depending on projects).

Frustum culling is enabled by default in the default.render_script. If you have a custom render script, you need to create a frustum matrix, and pass it into your render.draw() calls.

NEW: Game loop now uses display.update_frequency to use variable/fixed frame rate (#6464)

The display.vsync is now deprecated, in favor of display.swap_interval:

display.swap_interval (integer) Sets the OpenGL swap interval (new property)

display.vsync - deprecated. Set to false to force a display.swap_interval = 0

display.update_frequency

  • 0 means variable frame rate
  • != 0 means fixed frame rate. Capped at runtime towards the actual frame rate. I.e. you cannot update the game twice in a frame.

Message set_update_frequency to control the display.update_frequency at runtime.

NEW: Ignore focus lost/gain events for detection if app is in background (Android) (#6336)

Fixes issue when showing any activity in foreground paused the game loop on Android. It might be any activity: Ads, webview, alarm indication, a status icon popup, etc.

If the game loop paused work extensions can’t receive messages from the native side which is important for communication Lua<->C++<->Java.

NEW: Added dmGraphics api for querying the supported extensions (#6385)

This adds three new functions to the dmGraphics API:

  • Check if an extension is supported
bool IsExtensionSupported(HContext context, const char* extension);
  • Get the number of supported extensions
uint32_t GetNumSupportedExtensions(HContext context);
  • Get a supported extension
const char* GetSupportedExtension(HContext context, uint32_t index);
NEW: Floating point render targets (#6319)

The following constants are set if supported on the device and are otherwise nil if not supported:

  • render.FORMAT_RGB16F
  • render.FORMAT_RGB32F
  • render.FORMAT_RGBA16F
  • render.FORMAT_RGBA32F
  • render.FORMAT_R16F
  • render.FORMAT_RG16F
  • render.FORMAT_R32F
  • render.FORMAT_RG32F

Fixes issue when application crashes on start because of AVFAudio framework. Minimum iOS version increased to 9.0, it’s a requirement for Xcode 13. Info.plist file updated. If you use custom Info.plist make sure you apply the same change for MinimumOSVersion.

FIX: Changed default value for wasm streaming in html5 builds (#6466)

The option to stream the .wasm file in HTML5 builds was introduced and made the default option in Defold 1.2.130. This option will load faster and use less memory, but it requirers the server to respond with content type “application/wasm” for it to work. This change makes the wasm streaming option an opt-in instead of the default for HTML5 build. It is now possible to enable wasm streaming via the html5.wasm_streaming game.project option.

FIX: Do not create animations for box nodes with one frame flipbook animations during gui scene creation (#6384)

When a GUI scene is created each textured box node with an implicit one frame flipbook animation will generate an internal animation reference. This is a problem in complex GUI scenes where these animations take up animation slots towards the max animation count (currently 1024). This is not necessarily a problem but if there are a lot of these nodes and they are disabled in the init() function of an attached gui_script it means that the animations will not complete until the node is enabled.

This fix adds a check on scene creation for all textured box nodes with one frame animation and completes these animations immediately.

FIX: Label alpha not always working properly in html5 (#5835)

In HTML5 builds if a font is created with outline and shadow alpha set to 0 it still renders the outline behind the font if the font face itself is (semi-)transparent. The problem was caused by a difference in texture format between different platforms (GL_LUMINANCE vs GL_RED) and how these are sampled in the shader, (L,L,L,1) vs (R,0,0,1). This, combined with the fact that if the font was a bitmap ttf font, the face, outline and shadow alpha weren’t copied to the compiled font, was the cause of the problem.

FIX: Improved error handling when using multiple tilemap collision objects in a single game object (#6386)

When using tilemap.set_tile() we currently broadcast a message to all collision components on the same game object that a tile was changed. This is potentially problematic if there are multiple collision components referencing different tilemaps as their shapes because all collision components will react to the message and update, regardless if they used the same tilemap shape or not. What’s worse is if the tilemaps have different number of layers it will in fact result in a crash.

This kind of very loose coupling between tilemaps and collision components is unfortunate and does only really work well in a scenario where you have ONE tilemap and ONE collision component using the tilemap as its shape. Solving this design flaw is not covered by this fix which only adds improved error handling to avoid a crash.

FIX: Correctly scale convex collision shapes in nested factory created game objects (#6373)

Child game objects containing convex collision shapes were not correctly scaled when created using a collection factory. Previously only the first four vertices of the shape were scaled. This works for a box shape but obviously not for a more complex shape.

FIX: Better handling of Android configuration changes (#3163)

Some device configurations can change during runtime (such as screen orientation, keyboard availability, global font size, etc). When such a change occurs, Android restarts the running game Activity. This behavior may be a reason for immediate app closing that looks like a crash and sometimes the reason for ANRs.

This fix adds all possible configuration changes into the lists configuration changes that the activity will handle itself (android:configChanges in AndroidManifest.xml)

AndroidManifest.xml has changed. Make sure you have these changes in your custom AndroidManifest.xml if you use one.

Editor

FIX: Better error handling if a project contains Clojure files (#6374)

Our Clojure plugin system expect Clojure files to return a function to call when the plugin is loaded. Previously the editor crashed if a Clojure file didn’t return a function. With this fix the editor will handle this and log that it failed to load the plugin.

FIX: Make sure particle fx duration doesn’t go below 0 (#6368)

The duration of a particle emitter can be configured to go below 0 if using a spread value larger than the duration. If this happens while previewing a particle fx animation in the editor the whole editor will freeze. Using a negative duration at runtime should also not be allowed. This fix will prevent the duration from becoming negative.