Defold 1.2.164 has been released

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

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

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.”

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

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

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:

3 Likes

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

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

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

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:

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

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

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

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

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

Hi,
I’ve tried to reproduce the issue with other my apps without native extensions and got the same error in console.

Steps to reproduce:

  • run app
  • wait for device sleeping
  • wakeup device
  • an app immediate collapses (collapses if debug bundle or just freeze if release bundle)

An open source example for testing: https://github.com/Dragosha/slasher-prototype

Could you try to make iOS bundle of this one and test it?


I tested on iPad6,7 (iPad Pro 12.9" first generation) OS Version: iPhone OS 13.2.3 (17B111)
Full crash reports: https://www.dropbox.com/sh/nxi5xgm9gwqkcbn/AABMb9aei034CIFKjFD9pFKma?dl=0

Short:

"app_name":"Slasherprototype","timestamp":"2019-12-16 13:14:12.54 +0500","app_version":"1.0","slice_uuid":"ced35aed-ca09-323f-b83f-69012e514433","adam_id":0,"build_version":"1.0","bundleID":"com.dragosha.slasher","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 13.2.3 (17B111)","incident_id":"AC8B7325-3F47-431D-868E-B53DC6C58D60","name":"Slasherprototype"}
Incident Identifier: AC8B7325-3F47-431D-868E-B53DC6C58D60
CrashReporter Key:   6729a68f7454a798696efaf75cc9613cc6a6ddb9
Hardware Model:      iPad6,7
Process:             Slasherprototype [2379]
Path:                /private/var/containers/Bundle/Application/AA854BAC-7041-45E8-84A6-965A07872824/Slasher-prototype.app/Slasherprototype
Identifier:          com.dragosha.slasher
Version:             1.0 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.dragosha.slasher [978]


Date/Time:           2019-12-16 13:14:12.3476 +0500
Launch Time:         2019-12-16 13:10:54.1805 +0500
OS Version:          iPhone OS 13.2.3 (17B111)
Release Type:        User
Baseband Version:    n/a
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Thread 0 name:  engine_main  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001815c7ec4 0x1815a3000 + 151236
1   libsystem_pthread.dylib       	0x00000001814e3774 0x1814e1000 + 10100
2   libsystem_c.dylib             	0x00000001814378c0 0x1813c4000 + 473280
3   libsystem_c.dylib             	0x0000000181437850 0x1813c4000 + 473168
4   libsystem_c.dylib             	0x0000000181436c64 0x1813c4000 + 470116
5   Slasherprototype              	0x0000000102688674 0x102474000 + 2180724
6   Slasherprototype              	0x00000001024d81ec 0x102474000 + 410092
7   Slasherprototype              	0x0000000102530b6c 0x102474000 + 772972
8   Slasherprototype              	0x0000000102535a8c 0x102474000 + 793228
9   Slasherprototype              	0x000000010247b088 0x102474000 + 28808
10  Slasherprototype              	0x000000010247bd38 0x102474000 + 32056
11  Slasherprototype              	0x000000010263b300 0x102474000 + 1864448
12  QuartzCore                    	0x00000001880dc860 0x1880cb000 + 71776
13  IOKit                         	0x000000018270e930 0x182708000 + 26928
14  CoreFoundation                	0x0000000181724670 0x1816a4000 + 525936
15  CoreFoundation                	0x000000018174de40 0x1816a4000 + 695872
16  CoreFoundation                	0x000000018174d56c 0x1816a4000 + 693612
17  CoreFoundation                	0x0000000181748440 0x1816a4000 + 672832
18  CoreFoundation                	0x00000001817478a0 0x1816a4000 + 669856
19  GraphicsServices              	0x000000018b69f328 0x18b69c000 + 13096
20  UIKitCore                     	0x0000000185838740 0x184e37000 + 10491712
21  Slasherprototype              	0x000000010247be98 0x102474000 + 32408
22  libdyld.dylib                 	0x00000001815d2360 0x1815d1000 + 4960
4 Likes

Hi @Dragosha, I’m trying to reproduce this issue, but I cannot seem to do so.
Do you still see this crash?

Hi @Mathias_Westerdahl , on old builds (May 2020), yes, still. I will test with 171 and back to comments.

1 Like