Defold 1.2.164 has been released

#1

Defold 1.2.164

In this sprint we’ve added support for multi touch on HTML5.

We’ve also fixed some iOS 13 related issues, related to our iOS app code.
(E.g. modal popups now work properly.)
This however means we had to do some big changes, so if you are an extension developer, be sure to read the more detailed information below.
The two major breaking changes are regarding callbacks outside of the main thread, and the registration flow for app delegates.

There have also been a number of other great additions and fixes.

Native Extensions

iOS Application Loop + OS Callbacks

This is a breaking change.

Previously, we had a custom startup procedure, allowing us to keep ownership of the event loop on the main thread.
Now however, we use a regular application loop, but that also means that callbacks from the OS is likely to not come from the main thread.
(This is how it was already working in our Android version.)
As a developer of UI applications, this is a common problem, you get a callback from a non UI thread, and need to pass info to the UI thread.
The solution in our case is to store the needed data for a period of time, and then process that data on the UI (main) thread.

As an example, you can look at extension-push,
where we protect an array with a mutex. We push to the array from the non-UI thread, and we read from the array on the UI thread.

dmExtension::RegisteriOSUIApplicationDelegate + dmExtension::UnregisteriOSUIApplicationDelegate

This is a breaking change.

Due to the new application loop, we needed a new way to register the app delegates.
This is now done via a static initializer in order to be able to hook into the engine before the UIApplicationMain()is called.

See example here

Lua Callbacks

To help in the process of refactoring our extensions, we added a few extra functions to manage Lua callbacks.

  • struct LuaCallbackInfo;
  • LuaCallbackInfo* dmScript::CreateCallback(L, index)
  • void dmScript::DestroyCallback(LuaCallbackInfo* cbk)
  • void dmScript::SetupCallback(LuaCallbackInfo* cbk)
  • void dmScript::TeardownCallback(LuaCallbackInfo* cbk);
  • lua_State* dmScript::GetCallbackLuaContext(LuaCallbackInfo* cbk)
  • int PCall(lua_State* L, int nargs, int nresult);

We also added a helper function void dmArray::Map(void (*fn)(T* value, void* ctx), void* ctx); that makes it easy to map a function over all elements in an array. We use it to handle all queued up callbacks from the non-UI threads.

You can see a practical example here

Callstack

In the event of a crash in the native code, our crash handler will be invoked.
We’ve now also added a printout, for easier sharing of info in such an event.

Debug symbols

We’ve made some improvements on how to deal with the debug symbols.
It’s important to keep debug symbols for each release of your game, for debugging any native issues that might pop up.
This is especially true if you are using native extensions, since we build a custom engine in the cloud for you.
(If you are not using native extensions, we keep the debug symbols on the download page)

When you opt to bundle with debug symbols, we will bundle these symbols next to your bundle.
The layout for each platform is different, here is the layout:

bundle_android
└── myapp
    ├── myapp.apk
    └── myapp.apk.symbols/  ** < BINARIES + MAPPING.TXT

bundle_html5
└── myapp
    ├── myapp.symbols       ** < THE .JS SYMBOLS
    └── myapp_asmjs.js

bundle_ios
├── myapp.dSYM/             ** < CORRECT FOLDER NAME + EXECUTABLE NAME
└── myapp.ipa

bundle_linux
└── myapp
    └── myapp.x86_64        ** < UNTOUCHED (UNSTRIPPED)

bundle_osx
├── myapp.app
└── myapp.dSYM/.../myapp    ** < CORRECT FOLDER NAME + EXECUTABLE NAME

bundle_win32
└── myapp
    ├── dmengine.pdb        ** < THE EXE IS RENAMED FROM dmengine.exe
    └── myapp.exe

Engine

  • Issue-3162 - Added: Multitouch support for html5 (DEF-3871)
  • Issue-4538 - Added: Added display.clear_color (RGBA) property
  • Issue-4508 - Added: Added ios.override_entitlements game.project option to specify an override entitlements file.
  • Issue-2812 - Added: Add support for http.request PATCH verb (#4560)
  • Issue-4427 - Fixed: Output native callstack on crash
  • Issue-4469 - Fixed: Fixed sys.reboot() crash (#4504)
  • Issue-4479 - Fixed: Use default google dns servers if no servers were found
  • Issue-4485 - Fixed: Optimized ResolveInstance method (checking for nil value)
  • Issue-4517 - Fixed: Set UTF-8 file encoding in bob.jar (#4520)
  • Issue-4519 - Fixed: NE - Set thread names in executable
  • Issue-4529 - Fixed: NE - Removed duplicate VC/include path from includes on Win32 builds
  • Issue-4539 - Fixed: Added the sound name to some error logging
  • Issue-4554 - Fixed: Make sure to set the correct start frame when playing an animation
  • Issue-4555 - Fixed: Restructured iOS App initialise flow
  • Issue-4556 - Fixed: Set initial mouse position to a valid value (#4557)
  • Issue-4558 - Fixed: Send correct camera id in set_view_projection id
  • Issue-4563 - Fixed: Better error handling when engine didn’t consume all bytes received from a http request
  • Issue-4540 - Fixed: NE - Updated to MSVC 2019 SDK
  • Issue-4542 - Fixed: NE - Recompiled libunwind and libvpx to reduce compiler warnings for OSX

Editor

  • DEFEDIT-2780 - Fixed: Setting file.encoding=UTF-8 for java to make it consistent on os’es (#4516)
  • DEFEDIT-4379 - Fixed: Remove remaining dashboard interactions
  • DEFEDIT-4498 - Fixed: Fix disappearing brush cursor in tile map editor
  • DEFEDIT-4510 - Fixed: Fixed bitmap font corruption when building some AngelCode fnt files
  • DEFEDIT-4532 - Fixed: Sort variables and table keys in debugger
  • Issue-4506 - Added: Added debug symbols button to the bundle dialog (#4507)
22 Likes

Simultaneous tapping Virtual gamepad example (SOLVED)
Win32 startup window color (DEF-3296) (SOLVED)
On_input: position is inaccurate until mouse movement (Issue-4556) (SOLVED)
Change camera pivot point (SOLVED)
Do Defold support touch in html5 build? (SOLVED)
pinned globally #2
0 Likes

#3

Is it lua_pcall()? I strongly advise not to use lua_pcall() when invoking callbacks, because when there is an error inside the callback, the developer is not notified about it. The app doesn’t work and it’s unclear why.

1 Like

#4

It is, and we don’t usually have troubles with it?
From the documentation (which isn’t up yet):

“This function wraps lua_pcall with the addition of specifying an error handler which produces a backtrace.
In the case of an error, the error is logged and popped from the stack.”

0 Likes

#5

Ok, it’s just before you were using lua_pcall() in the push extension without the error function and I didn’t like it.

0 Likes

#6

Well, we haven’t had access to all internal sdk functions in our extensions, but we’re getting there little by little. This one we’ve used for many years internally, we just had to temporarily switch to lua_pcall in the external code.

2 Likes

#7

There were somewhere a practical example of that, I remember I played @Dragosha’s Slasher based example on mobile browser, but now I can’t find it :confused:

0 Likes

#8
3 Likes

#9

Perhaps, I’ve found two issues on iOS with 1.2.164

  1. Crash an app after wakeup iOS.
  • run app
  • wait for device sleeping
  • wakeup device
  • an app immediate collapses

I’ve tested the game with and without Native extensions, the same results.
Tested on iPadOS 13.1.3, iPAD Pro 12.9 (first generation)

Console:

Also @sergey.lerg has something similar bug on his apps.

  1. Crash extension callback when there is an error in Lua callback.
    my case:

This bug is found Apple review team in my last build when try “restore purchases” (they tested on iPad running iOS 13.2.2), after that I had a little research and reproduced that on iPAD mini 2, iOS,12.3.1.

I fixed my Lua code and have no that issue anymore, BUT, old code worked with my Lua error a year…

sorry, no screen from console made.

2 Likes

#10

Hmm, I couldn’t reproduce it yet :confused:

About the crash log, can you perhaps download it with the Download container?

You’ll find this in the window XCode -> Devices and Simulators

0 Likes

#11

I have a crash log from a tester
LunarOrbit-2019-11-28-120919.txt (87.4 KB)

Happened after resuming the game after the ipad was locked.

1 Like

#12

Is this a vanilla build? I.e. no extensions?

|5   LunarOrbit                    |0x0000000104f87fa0 0x104cc0000 + 2916256|
|6   LunarOrbit                    |0x0000000104f87cd8 0x104cc0000 + 2915544|
|7   LunarOrbit                    |0x0000000104f879dc 0x104cc0000 + 2914780|

Since I assume it’s a custom build, and I don’t have the unstripped exe, I cannot symbolicate :confused:

0 Likes

#13

Many extensions. Can’t reliably reproduce it myself, so hard to make a case.

0 Likes

#14

Understandable. I’d like to remind anyone of keeping the exe+debug symbols for each release you do, for this exact purpose. :slight_smile:

2 Likes

#15

Hi guys, increased number of crashes for users with version 164 could not reproduce in debug thru
stacktrace:

0 match2 0x00000001012c54f8 _ZN7dmCrash7OnCrashEi + 96\n1 libsystem_platform.dylib 0x00000001b99e8894 4D8CF271-94F7-3D09-8E5E-5E462A8B3B17 + 34964\n2 libsystem_pthread.dylib 0x00000001b99f1c00 F8B082D8-24D9-3B1E-B80B-645FC8A88E14 + 27648\n3 libsystem_c.dylib 0x00000001b9941844 abort + 100\n4 libsystem_c.dylib 0x00000001b9940c64 err + 0\n5 match2 0x00000001012a7f6c +[IndexedPosition positionWithIndex:] + 0\n6 match2 0x00000001012a7ca4 -[EAGLView destroyFramebuffer] + 224\n7 match2 0x00000001012a79a8 -[EAGLView layoutSubviews] + 64\n8 UIKitCore 0x00000001be1d7604 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15296004\n9 QuartzCore 0x00000001c072578c 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 1378188\n10 QuartzCore 0x00000001c072b908 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 1403144\n11 QuartzCore 0x00000001c0736528 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 1447208\n12 QuartzCore 0x00000001c067eed0 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 696016\n13 QuartzCore 0x00000001c06a8bbc 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 867260\n14 UIKitCore 0x00000001bdd4bd0c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10530060\n15 UIKitCore 0x00000001bdd4b080 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10526848\n16 UIKitCore 0x00000001bdd4bc44 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10529860\n17 UIKitCore 0x00000001be1ca09c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15241372\n18 UIKitCore 0x00000001bdd4b9e4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10529252\n19 UIKitCore 0x00000001bd3840c4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 274628\n20 UIKitCore 0x00000001bdf731d8 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 12788184\n21 UIKitCore 0x00000001bdd4b8b4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10528948\n22 UIKitCore 0x00000001bdd4d268 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10535528\n23 FrontBoardServices 0x00000001bee26184 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 344452\n24 FrontBoardServices 0x00000001bee261d4 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 344532\n25 FrontBoardServices 0x00000001bee25d74 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 343412\n26 UIKitCore 0x00000001bdd4d190 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10535312\n27 UIKitCore 0x00000001bdd4c6d0 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10532560\n28 UIKitCore 0x00000001bdd4d050 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10534992\n29 UIKitCore 0x00000001bd383fbc B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 274364\n30 UIKitCore 0x00000001bd38423c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 275004\n31 UIKitCore 0x00000001bdd4cda0 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10534304\n32 UIKitCore 0x00000001be266d0c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15883532\n33 UIKitCore 0x00000001be266b94 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15883156\n34 UIKitCore 0x00000001bd383814 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 272404\n35 UIKitCore 0x00000001bd38483c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 276540\n36 UIKitCore 0x00000001bd8f74e4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 5989604\n37 FrontBoardServices 0x00000001beddf2f8 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 54008\n38 FrontBoardServices 0x00000001bee03dd8 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 204248\n39 FrontBoardServices 0x00000001bede8fb4 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 94132\n40 FrontBoardServices 0x00000001bee03d0c E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 204044\n41 libdispatch.dylib 0x00000001b99a7184 B7EED4C7-560D-3DA6-9B50-ED52A150AAC6 + 377220\n42 libdispatch.dylib 0x00000001b9981420 B7EED4C7-560D-3DA6-9B50-ED52A150AAC6 + 222240\n43 FrontBoardServices 0x00000001bee284c8 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 353480\n44 FrontBoardServices 0x00000001bee28194 E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 352660\n45 FrontBoardServices 0x00000001bee286bc E4498CED-0520-3E13-BAF0-00C5CF8C7108 + 353980\n46 CoreFoundation 0x00000001b9c577c4 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 694212\n47 CoreFoundation 0x00000001b9c5771c FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 694044\n48 CoreFoundation 0x00000001b9c56eb4 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 691892\n49 CoreFoundation 0x00000001b9c52000 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 671744\n50 CoreFoundation 0x00000001b9c518a0 CFRunLoopRunSpecific + 464\n51 GraphicsServices 0x00000001c3ba9328 GSEventRunModal + 104\n52 UIKitCore 0x00000001bdd42740 UIApplicationMain + 1936\n53 match2 0x0000000100f92cc8 _Z11engine_mainiPPc + 160\n54 libdyld.dylib 0x00000001b9adc360 1DB44CE7-7030-3D97-9461-6EC743F47783 + 4960\n

1 Like

#16

This is for HTML5 builds (tested with Scale mode: Downscale Fit, but probably the same for other scaling modes)

On 1.2.163:
window.WINDOW_EVENT_RESIZED is being called immediately upon game launch (callback is registered from init)

On 1.2.164:
window.WINDOW_EVENT_RESIZED is only called if you start resizing the browser manually. However, the original game project’s dimensions may already be different upon game launch, so there is currently no way to detect the new dimensions immediately?

3 Likes

#17

We have in our backlog for 1.2.165 to add more functions to window.* to read the window size at any time, something like window.get_size()

3 Likes