Native Extensions


#142
  1. Yes, the default engine includes both 2D and 3D physics
  2. Unfortunately, we need to do some more work for that to happen. Currently you can only use both engines or none. (Added DEF-3097 for this)
  3. Vpx is for the recording functionality yes

#143

Whitch function should be on the place of zero?


#144

OnMessage or something like that. It says in the docs


#145

// DM_DECLARE_EXTENSION(symbol, name, app_init, app_final, init, update, on_event, final)


#146

Exactly as @dapetcu21 and @sicher said, and you can find the function declaration here.
Currently, we only support two events, app activate/deactive, but in the future we could add more events.


#147

Is Activate calls every time when focus back? Something like applicationDidBecomeActive on ios?
Thanks for the link to docs, I missed when searching.


#148

The activate/deactivate events should happen at the same as the Lua window events. We currently have some discrepancies registered in DEF-2520: Android + HTML5: missing first focus gained, Windows: getting the focus lost when focus gained, iOS: no focus lost on voice control focus.


#149

Hello, I need your help, guys.
I have strange memory leak in .mm file:

But with this simple code:

Code:

void DefAppsFlyer_trackEvent(const char*eventName, dmArray<TrackData>* trackData)
{
  NSMutableDictionary* newDict = [NSMutableDictionary dictionary];
  NSString* key;
  NSString* value;
  TrackData data;
  for(uint32_t i = 0; i != trackData->Size(); i++)
  {
    data = (*trackData)[i];
    key = [NSString stringWithUTF8String: data.key];
    value = [NSString stringWithUTF8String: data.value];
    newDict[key] = value;
  }
}

What I am doing wrong here?
As I understand I am using only “safe” variable creation, and they should be free-up the memory.
I have memory leak even if I leave only one line:

NSMutableDictionary* newDict = [NSMutableDictionary dictionary];

Is this my mistake? Or something works wrong?


#150

Is that code is running on a thread other than main thread?

Does this help?
@autoreleasepool {
// your code inside method
}


#151

Yes, it helps in situation with creation of Dictionary with Strings, but has no effect when I add SDK call:

[[AppsFlyerTracker sharedTracker] trackEvent: evName withValues: newDict];

=(


#152

I checked with:

if ([NSThread isMainThread])

it’s the Main thread.

In cocos2d ( appsflyer sdk implementation ) I found only one autoreleasepool mentioning :


#153

I tried the same test with Android (JNI) implementation - and it works without memory leak

void DefAppsFlyer_trackEvent(const char*eventName, dmArray<TrackData>* trackData)
{
  AttachScope attachscope;
  JNIEnv* env = attachscope.m_Env;
  jclass hashMapClass = env->FindClass("java/util/HashMap");
  jmethodID hashMapInit = env->GetMethodID(hashMapClass, "<init>", "(I)V");
  jobject hashMapObj = env->NewObject(hashMapClass, hashMapInit, trackData->Size());
  jmethodID hashMapId = env->GetMethodID(hashMapClass, "put","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");

  TrackData data;
  jstring key;
  jstring value;
  for(uint32_t i = 0; i != trackData->Size(); i++)
  {
    data = (*trackData)[i];
    key = env->NewStringUTF(data.key);
    value = env->NewStringUTF(data.value);
    env->CallObjectMethod(hashMapObj, hashMapId, key, value);

    env->DeleteLocalRef(key);
    env->DeleteLocalRef(value);
  }
  jclass cls = GetClass(env, JAR_PATH);
  jmethodID method = env->GetStaticMethodID(cls, "DefAppsFlyer_trackEvent","(Landroid/app/Activity;Ljava/lang/String;Ljava/util/Map;)V");
  jstring jEventName = env->NewStringUTF(eventName);
  -- env->CallStaticVoidMethod(cls, method, dmGraphics::GetNativeAndroidActivity(), jEventName, hashMapObj);

  env->DeleteLocalRef(hashMapClass);
  env->DeleteLocalRef(hashMapObj);
  env->DeleteLocalRef(cls);
  env->DeleteLocalRef(jEventName);
}

What’s wrong with my objC implementation?


#154

Which version of macos SDK used on the build server?
I want to use CGDisplayBitsPerPixel but I can’t.

UPD: I found a way to get BPP from the CGDisplayModeCopyPixelEncoding string, but question about macos SDK still actual.


#155

Currently, it’s MacOSX10.12, but I’m currently updating to MacOSX10.13, and I’m anticipating that we’ll support it with the next release. I’m also adding iPhoneOS11.2 support.


#156

As for supporting deprecated functions, like CGDisplayBitsPerPixel, we’ll see how to deal with that in the future. The question is, if you open a 4 year old project, which at the time relied on a certain function. And now, with the latest sdk, that function isn’t even there yet (e.g. the upcoming removal of the system() function from iPhoneOS.sdk), should we support it? And how would we go about doing it? We’ll have to discuss that in the team.


#157

xcodebuild supports a different versions of sdk (-sdk macosx10.4 or -sdk macosx10.5), but as i remember you are using gcc for compilation, maybe it possible to create custom parameter? or something like this…


#158

I think it’s solvable, but we’ll have to discuss it internally.


#159

As I understand appmanifest do not work if I have no NE in my project?
I try to add release.appmanifest to my project, where I have no NE, and I still see logs when I build the project (cmd+B), but If I adding any NE to this project logs turns off.
Is this cmd+B only or game bundle has the same issue? (is it bug?)

UPD:
ok, this is only cmd-b only issue - not a problem for me, but, I think, it can be issue for peoples who want to check some logic that uses is_debug.


#160

Having just an app.manifest is totally fine. It will strip your executable. But, as you mentioned, the old bug of not respect the “release” button if you bundle the game. But for CMD+B, it should be the same (debug log enabled)


#161

I tried to build DefUnityAds NE using 1.2.123, and recieved next error:

Description	Resource	Path	Location	Type
Build server output: clang++ -c -arch arm64 -target arm-apple-darwin12 -isysroot /opt/iPhoneOS11.2.sdk/ -m64 -O2 -g -miphoneos-version-min=6.0 -DDM_PLATFORM_IOS  -fno-exceptions  -Iupload/defunityads/include  -F/tmp/job3157322890644293834/upload/defunityads/lib/ios  -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//sdk/include  upload/defunityads/src/DefUnityCallback.cpp -obuild/DefUnityCallback.cpp_0.o
In file included from upload/defunityads/src/DefUnityCallback.cpp:2:
In file included from upload/defunityads/src/DefUnityCallback.h:3:
In file included from /var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/sdk.h:11:
/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/dlib/log.h:118:2: warning: "DLIB_LOG_DOMAIN is not defined" [-W#warnings]
#warning "DLIB_LOG_DOMAIN is not defined"
 ^
1 warning generated.

clang++ -c -arch arm64 -target arm-apple-darwin12 -isysroot /opt/iPhoneOS11.2.sdk/ -m64 -O2 -g -miphoneos-version-min=6.0 -DDM_PLATFORM_IOS  -fno-exceptions  -Iupload/defunityads/include  -F/tmp/job3157322890644293834/upload/defunityads/lib/ios  -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//sdk/include  upload/defunityads/src/utils/LuaUtils.cpp -obuild/LuaUtils.cpp_1.o
In file included from upload/defunityads/src/utils/LuaUtils.cpp:1:
In file included from upload/defunityads/src/utils/LuaUtils.h:3:
In file included from /var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/sdk.h:11:
/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/dlib/log.h:118:2: warning: "DLIB_LOG_DOMAIN is not defined" [-W#warnings]
#warning "DLIB_LOG_DOMAIN is not defined"
 ^
1 warning generated.

clang++ -c -arch arm64 -target arm-apple-darwin12 -isysroot /opt/iPhoneOS11.2.sdk/ -m64 -O2 -g -miphoneos-version-min=6.0 -DDM_PLATFORM_IOS  -fno-exceptions  -Iupload/defunityads/include  -F/tmp/job3157322890644293834/upload/defunityads/lib/ios  -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//sdk/include  upload/defunityads/src/DefUnityAds.cpp -obuild/DefUnityAds.cpp_2.o
upload/defunityads/src/DefUnityAds.cpp:30:26: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
        char *placementId_lua = "";
                                ^
upload/defunityads/src/DefUnityAds.cpp:39:29: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
    char *placementId_lua = "";
                            ^
2 warnings generated.

clang++ -c -arch arm64 -target arm-apple-darwin12 -isysroot /opt/iPhoneOS11.2.sdk/ -m64 -O2 -g -miphoneos-version-min=6.0 -DDM_PLATFORM_IOS  -fno-exceptions  -Iupload/defunityads/include  -F/tmp/job3157322890644293834/upload/defunityads/lib/ios  -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include -I/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//sdk/include  upload/defunityads/src/objc/DefUnityAdsIOS.mm -obuild/DefUnityAdsIOS.mm_3.o
In file included from upload/defunityads/src/objc/DefUnityAdsIOS.mm:3:
In file included from upload/defunityads/src/objc/../DefUnityCallback.h:3:
In file included from /var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/sdk.h:11:
/var/extender/sdk/46d8b7e63d7e0f0f4acd545c46d25ca2b227a806/defoldsdk//include/dmsdk/dlib/log.h:118:2: warning: "DLIB_LOG_DOMAIN is not defined" [-W#warnings]
#warning "DLIB_LOG_DOMAIN is not defined"
 ^
In file included from upload/defunityads/src/objc/DefUnityAdsIOS.mm:5:
In file included from /opt/iPhoneOS11.2.sdk//System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:22:
In file included from /opt/iPhoneOS11.2.sdk//System/Library/Frameworks/AVFoundation.framework/Headers/AVAnimation.h:11:
In file included from /opt/iPhoneOS11.2.sdk//System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:128:
/opt/iPhoneOS11.2.sdk//System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:26:49: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'uuid_t' (aka 'unsigned char [16]')
- (instancetype)initWithUUIDBytes:(const uuid_t _Nullable)bytes;
                                                ^
/opt/iPhoneOS11.2.sdk//System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:29:30: error: nullability specifier '_Nonnull' cannot be applied to non-pointer type 'uuid_t' (aka 'unsigned char [16]')
- (void)getUUIDBytes:(uuid_t _Nonnull)uuid;
                             ^
1 warning and 2 errors generated.

	DefUnityAds.cpp	/DefUnityAds/content/defunityads/src	Unknown	Problem

I checked macOS 10.13 release notes, and didn’t find big changes in AVFoundation , same thing with AppKit in other NE.

Can you help me with this issue?