Defold 1.2.189 has been released

Release notes

We’re continuing our focus on improving stability to the engine, especially ANR’s on Android.
And we have added a new major update with regards how to use uniform arrays.

The bob.jar build pipeline has also received a big performace boost.
E.g. it previously processed textures in a redundant manner.

BREAKING CHANGE in dmSDK!

Due to the changes with uniform arrays, we had to make some breaking changes to our DefoldSDK.
The changes are in our quite new parts of the SDK, and so we only really expect it to affect the extension-spine / extension-rive, which we have already updated to use the new sdk calls.

Uniform arrays

This sprint we’ve support for uniform arrays.
It allows you to set multiple values to the same uniform in your shader:

uniform lowp vec4 example[16];

To use it, we’ve added an options table to go.get()/go.set(), which allows you to specify the array index.
The index in Lua is 1-based, and in the shader it’s 0-based.

-- set the first vector4 in the array: example[0] = v
go.set(url, "example", vmath.vector4(1,1,1,1), {index=1})

-- set the last vector4 in the array: example[15] = v
go.set(url, "example", vmath.vector4(2,2,2,2), {index=16})

-- set an element of a vector4 in the array: example[0].x = 7
go.set(url, "example.x", 7, {index=1})

Note:

  • We currently cannot set more than one value in the editor
  • It only supports vmath.vector4

resource.get_text_metrics

We’ve deprecated the label.get_text_metrics() and gui.get_text_metrics() in favor of the new
resource.get_text_metrics()

The benefit is that you don’t have to create an instance before figuring out the size of a text.
For gui, we’ve also added gui.get_font_resource(node) in order to get the font handle.

local font = go.get("#label", "font") -- or gui.get_font_resource(node)
local metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog")

Engine

  • Issue-3692 - Added: Added support for uniform arrays

  • Issue-5874 - Fixed: Bob: Avoid building of textures which are not used in components

  • Issue-6092 - Fixed: Make string output consistent in userdata objects

  • Issue-6093 - Fixed: Do not throw Unable to play animation error, when changing texture for sprite

  • Issue-6106 - Fixed: Fixed fallback when live update fails to load .dmanifest

  • Issue-6116 - Fixed: Better responding to Audio Session Interruptions on iOS

  • Issue-6117 - Fixed: Bob: Don’t calculate a cache key if the resource cache is disabled

  • Issue-6119 - Fixed: Bob: Ignore the build cache for basic copy tasks

  • Issue-6120 - Fixed: Bob: Improved the require parser to better handle trailing commands

  • Issue-6132 - Fixed: Add resource.get_text_metrics()

  • Issue-6136 - Fixed: Updated some of the API docs

  • Issue-6147 - Fixed: Always release the mesh buffer resource

  • Issue-6099 - Fixed: NE: Added dmGameObject::PostDDF, dmMessage::PostDDF helper functions

  • Issue-6102 - Fixed: NE: Added dmScript::IsQuat and dmScript::IsMatrix4

  • Issue-6121 - Fixed: NE: Add dmScript::UrlToString to dmsdk for easier error reporting

Fixes for source code support when building locally

  • Issue-6091 - Fixed: Source: Target only x86_64-darwin until official M1 support
  • Issue-6095 - Fixed: Source: Converted easy_install packages to pip packages
17 Likes

When building the project I got these errors in the new spine extension:

/defold-spine/src/comp_spine_model.cpp
	Line 115: unused variable 'render_context' [-Wunused-variable]
        dmRender::HRenderContext render_context = context->m_RenderContext;
                                 ^
	Line 479: unused variable 'ctx' [-Wunused-variable]
        SpineModelContext* ctx = (SpineModelContext*)params.m_Context;
                           ^
	Line 716: no matching function for call to 'SetRenderConstant'
        dmGameSystem::SetRenderConstant(component->m_RenderConstants, GetMaterial(component, component->m_Resource), name_hash, element_index, var);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Line 716: candidate function not viable: requires 4 arguments, but 5 were provided
    void SetRenderConstant(HComponentRenderConstants constants, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values);
         ^
	Line 716: candidate function not viable: requires 6 arguments, but 5 were provided
    void SetRenderConstant(HComponentRenderConstants constants, dmRender::HMaterial material, dmhash_t name_hash, int32_t value_index, uint32_t* element_index, const dmGameObject::PropertyVar& var);
         ^
	Line 753: too few arguments to function call, expected 6, have 5
                        dmGameObject::PropertyVar(ddf->m_Value), CompSpineModelSetConstantCallback, component);
                                                                                                             ^
	Line 753: 'SetMaterialConstant' declared here
    dmGameObject::PropertyResult SetMaterialConstant(dmRender::HMaterial material, dmhash_t name_hash, const dmGameObject::PropertyVar& var, int32_t value_index, CompSetConstantCallback callback, void* callback_user_data);
    ^
	Line 873: too few arguments to function call, expected 7, have 6
        return dmGameSystem::GetMaterialConstant(GetMaterial(component, component->m_Resource), params.m_PropertyId, out_value, true, CompSpineModelGetConstantCallback, component);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                  ^
	Line 873: 'GetMaterialConstant' declared here
    dmGameObject::PropertyResult GetMaterialConstant(dmRender::HMaterial material, dmhash_t name_hash, int32_t value_index, dmGameObject::PropertyDesc& out_desc, bool use_value_ptr, CompGetConstantCallback callback, void* callback_user_data);
    ^
	Line 926: too few arguments to function call, expected 6, have 5
        return dmGameSystem::SetMaterialConstant(GetMaterial(component, component->m_Resource), params.m_PropertyId, params.m_Value, CompSpineModelSetConstantCallback, component);
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                 ^
	Line 926: 'SetMaterialConstant' declared here
    dmGameObject::PropertyResult SetMaterialConstant(dmRender::HMaterial material, dmhash_t name_hash, const dmGameObject::PropertyVar& var, int32_t value_index, CompSetConstantCallback callback, void* callback_user_data);
    ^

And some warnings as well:

upload/defold-spine/include: warning: directory does not exist.
	Line 2: In file included from build/defold-spine/spine_ddf.cpp:2:
In file included from /var/extender/sdk/794112e7e21be5d00f1cc70bb891b80ded986c6f/defoldsdk//include/ddf/ddf_math.h:24:
In file included from /var/extender/sdk/794112e7e21be5d00f1cc70bb891b80ded986c6f/defoldsdk//sdk/include/dmsdk/vectormath/cpp/vectormath_aos.h:40:
private field 'd' is not used [-Wunused-private-field]
    float d;
          ^
	Line 2: private field 'd' is not used [-Wunused-private-field]
    float d;
          ^
1 Like

Thanks, I forgot to create a new release of that extension:

2 Likes

Also have some issues while building the app:

Thanks. Those are just warnings. Do you get any errors?

I have the same issues with comp_spine_model.cpp, which are crashing the build, but those were already mentioned in this thread.

1 Like

Please make sure you use the latest version of the admob extension or at least this version https://github.com/defold/extension-admob/releases/tag/2.0.5

1 Like

There’s no mention of crashes in this thread?

Fixed all the issues/warnings and I would like to share that project is building almost instantly! Wonderful, thanks!!

2 Likes

I meant the spine-extension issues.

2 Likes

Now, everything is fine. Thanks

2 Likes

I get error:
ERROR:GAMESYS: Tried to set index outside of bounds for property tint[1]: 1015732467

when I call this:
sprite.set_constant(spriteUrl, "tint", vmath.vector4(0.4, 1.3, 1.3, 0.8))

this sprite has default material sprite.material;
my game has custom render script, but anything works fine in version 188.

2 Likes

I have the same problem. I tried changing the uniform into an array with size 1 and specify index the the set_constant call, but I couldn’t get it to work.

1 Like

@Sw_Alex @Klear
It seems I missed updating our deprecated methods of setting render constants.
Could you try using go.set instead?

go.set("#sprite", "tint", vmath.vector4(0.4, 1.3, 1.3, 0.8))
2 Likes

That did the trick. Thanks!

1 Like

Great!
I’ve also fixed the “sprite.set_constant()” function, and I’ve started the release process again, hopefully I can finish that process today. If not, it’ll be available tomorrow.

EDIT: The release has now been updated with this fix.

8 Likes

Is it aplicabele for models too?
i used model.set_constant in 1.2.188, but 1.2.189 crashes on it, when i trying to send “draw_top_pos” constant to it
model.set_constant(modelHandle, "draw_top_pos", vmath.vector4(0.0, 300.0, 0.0, 0.0))

it is used in shader to determine draw region

varying mediump vec2 var_texcoord0;
uniform lowp sampler2D tex0;
uniform lowp vec4 tint;
uniform lowp vec4 draw_top_pos;

#define TRANSPARENT vec4(0.0, 0.0, 0.0, 0.0)

void main()
{
    if (gl_FragCoord.y < draw_top_pos.y )
    {
        lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
        gl_FragColor = texture2D(tex0, var_texcoord0.xy) * tint_pm; 
    } else {
        gl_FragColor = TRANSPARENT; 
    }  
}

Errors:

Assertion failed: Capacity() - Size() > 0, file D:\a\defold\defold\tmp\dynamo_home\sdk\include\dmsdk/dlib/array.h, line 499
INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\sublustris\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:

ERROR:CRASH:  0 0x13F6DDCC0 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:142

ERROR:CRASH:  1 0x13FA4E0E4 raise /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/misc/signal.cpp:547

ERROR:CRASH:  2 0x13FA4120C abort /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/abort.cpp:71

ERROR:CRASH:  3 0x13FA40458 common_assert_to_stderr<wchar_t> /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:186

ERROR:CRASH:  4 0x13FA3FF7C _wassert /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:443

ERROR:CRASH:  5 0x13F748C40 dmGameSystem::SetRenderConstant D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_private.cpp:429

ERROR:CRASH:  6 0x13F8B4BF0 dmGameSystem::CompModelSetConstantCallback D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_model.cpp:767

ERROR:CRASH:  7 0x13F74A420 dmGameSystem::SetMaterialConstant D:\a\defold\defold\engine\gamesys\src\gamesys\gamesys_private.cpp:186

ERROR:CRASH:  8 0x13F8B1900 dmGameSystem::CompModelOnMessage D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_model.cpp:804

ERROR:CRASH:  9 0x13F7291C0 dmGameObject::DispatchMessagesFunction D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2230

ERROR:CRASH: 10 0x13F748600 dmMessage::InternalDispatch D:\a\defold\defold\engine\dlib\src\dlib\message.cpp:542

ERROR:CRASH: 11 0x13F728AC0 dmGameObject::DispatchMessages D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2304

ERROR:CRASH: 12 0x13F729E60 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2449

ERROR:CRASH: 13 0x13F7FA840 dmGameSystem::CompCollectionProxyUpdate D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collection_proxy.cpp:281

ERROR:CRASH: 14 0x13F729E60 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2441

ERROR:CRASH: 15 0x13F751FD0 dmEngine::Step D:\a\defold\defold\engine\engine\src\engine.cpp:1523

ERROR:CRASH: 16 0x13F74F020 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:1983

ERROR:CRASH: 17 0x13F754550 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:69

ERROR:CRASH: 18 0x13F6C4270 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:132

ERROR:CRASH: 19 0x13FA04024 __scrt_common_main_seh d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
ERROR:CRASH: 20 0x775E59E0 BaseThreadInitThunk <unknown>:0
ERROR:CRASH: 21 0x7781B350 RtlUserThreadStart <unknown>:0

2 Likes

Strange, the engine code looks like it’s updated to work in the same fashion, but since it crashes, we’ve clearly missed something.

Yes, you can migrate to using go.set() instead.

its not applicable to the discussion, but why use gl_FragColor = TRANSPARENT instead discard keyword. In your case if one 3d model overlap other you will see background instead model behind in transparent pixels place.

1 Like

Using go.set() solves the problem with fragment constants, thank you.
But with vertex constants it is not working :frowning:

go.set(modelHandle, "a", a_point_vec4)
go.set(modelHandle, "b", b_point_vec4)

leads to:

Assertion failed: Capacity() - Size() > 0, file D:\a\defold\defold\tmp\dynamo_home\sdk\include\dmsdk/dlib/array.h, line 499
INFO:CRASH: Successfully wrote Crashdump to file: C:\Users\sublustris\AppData\Roaming\Defold/_crash
ERROR:CRASH: CALL STACK:

ERROR:CRASH:  0 0x13F88DCC0 dmCrash::GenerateCallstack D:\a\defold\defold\engine\crash\src\backtrace_win32.cpp:142

ERROR:CRASH:  1 0x13FBFE0E4 raise /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/misc/signal.cpp:547

ERROR:CRASH:  2 0x13FBF120C abort /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/abort.cpp:71

ERROR:CRASH:  3 0x13FBF0458 common_assert_to_stderr<wchar_t> /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:186

ERROR:CRASH:  4 0x13FBEFF7C _wassert /tmp/job13373918990837803032/minkernel/crts/ucrt/src/appcrt/startup/assert.cpp:443

ERROR:CRASH:  5 0x13F8F8C40 dmGameSystem::SetRenderConstant D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_private.cpp:429

ERROR:CRASH:  6 0x13FA64BF0 dmGameSystem::CompModelSetConstantCallback D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_model.cpp:767

ERROR:CRASH:  7 0x13F8FA420 dmGameSystem::SetMaterialConstant D:\a\defold\defold\engine\gamesys\src\gamesys\gamesys_private.cpp:186

ERROR:CRASH:  8 0x13FA61D30 dmGameSystem::CompModelSetProperty D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_model.cpp:989

ERROR:CRASH:  9 0x13F8CF920 dmGameObject::SetProperty D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:3386

ERROR:CRASH: 10 0x13F8DC780 dmGameObject::Script_Set D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject_script.cpp:759

ERROR:CRASH: 11 0x13F82CF0E lj_BC_FUNCC <unknown>:0

ERROR:CRASH: 12 0x13F8851C0 lua_pcall <unknown>:0

ERROR:CRASH: 13 0x13F8A50C0 dmScript::PCallInternal D:\a\defold\defold\engine\script\src\script.cpp:1362

ERROR:CRASH: 14 0x13F8E6720 dmGameObject::RunScript D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:132

ERROR:CRASH: 15 0x13F8E4E50 dmGameObject::CompScriptUpdate D:\a\defold\defold\engine\gameobject\src\gameobject\comp_script.cpp:230

ERROR:CRASH: 16 0x13F8D9E60 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2441

ERROR:CRASH: 17 0x13F9AA840 dmGameSystem::CompCollectionProxyUpdate D:\a\defold\defold\engine\gamesys\src\gamesys\components\comp_collection_proxy.cpp:281

ERROR:CRASH: 18 0x13F8D9E60 dmGameObject::Update D:\a\defold\defold\engine\gameobject\src\gameobject\gameobject.cpp:2441

ERROR:CRASH: 19 0x13F901FD0 dmEngine::Step D:\a\defold\defold\engine\engine\src\engine.cpp:1523

ERROR:CRASH: 20 0x13F8FF020 dmEngineUpdate D:\a\defold\defold\engine\engine\src\engine.cpp:1983

ERROR:CRASH: 21 0x13F904550 dmEngine::RunLoop D:\a\defold\defold\engine\engine\src\engine_loop.cpp:69

ERROR:CRASH: 22 0x13F874270 engine_main D:\a\defold\defold\engine\engine\src\engine_main.cpp:132

ERROR:CRASH: 23 0x13FBB4024 __scrt_common_main_seh d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288

ERROR:CRASH: 24 0x775E59E0 BaseThreadInitThunk <unknown>:0

ERROR:CRASH: 25 0x7781B350 RtlUserThreadStart <unknown>:0

ERROR:CRASH: 

the strange thing is:
if i trying to do so:

    --go.set(modelHandle, "a", a_point_vec4)
    go.set(modelHandle, "b", b_point_vec4)

or so:

    go.set(modelHandle, "a", a_point_vec4)
    --go.set(modelHandle, "b", b_point_vec4)

it works unproper (shader needs both conctants to calculate position), but not crashes.

1 Like