Skip to content

Commit 9baaf23

Browse files
committed
Merge branch 'release/0.7.10'
2 parents b87500b + 9b12932 commit 9baaf23

File tree

19 files changed

+78
-38
lines changed

19 files changed

+78
-38
lines changed

.github/workflows/dart.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: subosito/flutter-action@v2
1919
with:
2020
# same with pubspec.yaml
21-
flutter-version: "2.2.0"
21+
flutter-version: "3.3.8"
2222
- run: flutter pub get
2323
working-directory: dart_native/example
2424
- run: flutter test --no-pub test/

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: subosito/flutter-action@v2
1919
with:
2020
# same with pubspec.yaml
21-
flutter-version: "2.2.0"
21+
flutter-version: "3.3.8"
2222
- run: flutter pub get
2323
working-directory: dart_native/example
2424
- run: flutter analyze --no-pub --no-current-package lib/ test/

dart_native/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.7.10
2+
3+
* [Fix] A dangling pointer on Android.
4+
* [Fix] DetachCurrentThread crash on Android.
5+
* [Feature] Collections support automatic type conversions on Android.
6+
17
## 0.7.9
28

39
* Bump to ffi >=1.1.2
-350 KB
Binary file not shown.
-238 KB
Binary file not shown.
-350 KB
Binary file not shown.
-379 KB
Binary file not shown.

dart_native/android/src/main/jni/include/dn_native_invoker.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
namespace dartnative {
1616

17-
typedef void(*InvokeCallback)(void *result, char *method, char **typePointers, int argumentCount);
18-
17+
typedef void(*InvokeCallback)(void *result, char *method, char **typePointers, int argumentCount, int isInterface);
1918

2019
JavaLocalRef<jclass> FindClass(const char *name, JNIEnv *env = nullptr);
2120

@@ -41,7 +40,8 @@ void *DoInvokeNativeMethod(jobject object,
4140
uint32_t stringTypeBitmask,
4241
void *callback,
4342
Dart_Port dartPort,
44-
TaskThread thread);
43+
TaskThread thread,
44+
bool isInterface);
4545

4646
jobject InvokeDartFunction(bool is_same_thread,
4747
int return_async,

dart_native/android/src/main/jni/src/dart_native.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void *InvokeNativeMethod(void *objPtr,
161161
auto type = TaskThread(thread);
162162
auto invokeFunction = [=] {
163163
return DoInvokeNativeMethod(object, methodName, arguments, dataTypes, argumentCount, returnType,
164-
stringTypeBitmask, callback, dartPort, type);
164+
stringTypeBitmask, callback, dartPort, type, isInterface);
165165
};
166166
if (type == TaskThread::kFlutterUI) {
167167
return invokeFunction();

dart_native/android/src/main/jni/src/dn_jni_env.cc

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,41 @@
88
namespace dartnative {
99

1010
static JavaVM *g_vm = nullptr;
11-
static pthread_key_t detach_key = 0;
11+
static pthread_key_t t_key = 0;
1212

1313
void InitWithJavaVM(JavaVM *vm) { g_vm = vm; }
1414

1515
void DetachThreadDestructor(void *arg) {
1616
DNDebug("detach from current thread");
1717
g_vm->DetachCurrentThread();
18-
detach_key = 0;
18+
t_key = 0;
1919
}
2020

2121
JNIEnv *AttachCurrentThread() {
22+
JNIEnv *env;
23+
env = (JNIEnv *)pthread_getspecific(t_key);
24+
if (env != nullptr) {
25+
return env;
26+
}
27+
2228
if (g_vm == nullptr) {
2329
return nullptr;
2430
}
2531

26-
if (detach_key == 0) {
27-
pthread_key_create(&detach_key, DetachThreadDestructor);
32+
if (t_key == 0) {
33+
pthread_key_create(&t_key, DetachThreadDestructor);
2834
}
29-
JNIEnv *env;
35+
3036
jint ret = g_vm->GetEnv((void **) &env, JNI_VERSION_1_6);
3137

3238
switch (ret) {
33-
case JNI_OK:return env;
34-
case JNI_EDETACHED:DNDebug("attach to current thread");
39+
case JNI_OK:
40+
pthread_setspecific(t_key, env);
41+
return env;
42+
case JNI_EDETACHED:
43+
DNDebug("attach to current thread");
3544
g_vm->AttachCurrentThread(&env, nullptr);
45+
pthread_setspecific(t_key, env);
3646
return env;
3747
default:DNError("fail to get env");
3848
return nullptr;

0 commit comments

Comments
 (0)