Giter Site home page Giter Site logo

dart-native / dart_native Goto Github PK

View Code? Open in Web Editor NEW
945.0 25.0 77.0 113.35 MB

Write iOS&macOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

License: BSD 3-Clause "New" or "Revised" License

Ruby 0.58% Objective-C 13.31% Dart 16.78% Objective-C++ 5.18% C 57.25% Java 1.88% CMake 0.08% C++ 4.59% Kotlin 0.01% Swift 0.30% Shell 0.05%
dart dart-objc dartobjc ffi dartffi runtime objective-c ios flutter android

dart_native's People

Contributors

ddrccw avatar hui19 avatar siriushe avatar trlste avatar wizzxu avatar yulingtianxia avatar zhongwuzw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart_native's Issues

安卓系统某些字符串在flutter获取是乱码

[✓] Flutter (Channel flutter-2.8-candidate.16, 2.10.5, on macOS 12.4 21F79 darwin-arm, locale
zh-Hans-CN)
Android SDK version 31.0.0
在安卓系统下,获取这个字符串,会返回乱码,请帮忙排查一下。
可以用自带的example项目unit_test.dart里getStringAsync处输入该字符串复现。

'[{"id":16,"regionid":1,"sectionid":"1","name":"台北車站生活圈","lat":"25.0440392","lng":"121.5139124"},{"id":17,"regionid":1,"sectionid":"1","name":"善導寺站生活圈","lat":"25.0432715","lng":"121.5247305"},{"id":22,"regionid":1,"sectionid":"1,5","name":"東門生活圈","lat":"25.0350275","lng":"121.5257406"},{"id":23,"regionid":1,"sectionid":"1","name":"植物園生活圈","lat":"25.0316631","lng":"121.5090781"},{"id":24,"regionid":1,"sectionid":"1","name":"古亭生活圈","lat":"25.0258859","lng":"121.5184339"},{"id":26,"regionid":1,"sectionid":"1,5","name":"公館生活圈","lat":"25.0155842","lng":"121.5298605"}]'

How to call global function

I've been trying to figure out how to call global functions using your perform method but have been having a lot of trouble. How would I go about doing this?
The method I'm trying to call:

 AudioFileOpenURL (
    CFURLRef inFileRef, 
    AudioFilePermissions inPermissions,
    AudioFileTypeID inFileTypeHint,
    AudioFileID	__nullable * __nonnull	outAudioFile
)

Thanks in advance!

DartNative's memory management strategy is strongly discouraged by the official Dart team :(

Hi, I was implementing the fully automatic memory management between Dart/Flutter and Rust (see fzyzcjy/flutter_rust_bridge#243), so I asked some questions to the Dart team, and I find the following reply also applies to your case (http://yulingtianxia.com/blog/2020/08/22/DartNative-Automatic-Memory-Management/):

I would strongly discourage anyone from using GC to manage non-Dart objects. If you want to manage native object lifetimes, have an explicit method like close or dispose to release native resources. GC might not ever run, or run too late.

The VM can be aware of external object size, but GC pressure comes from new allocations. It's really not that hard to get into a scenario where you have an external object that takes up very close to a ceiling of memory you want to use, but not enough to trigger a GC. Then, new allocations happen quickly and kick off a GC, but you then run out of memory (or file handles, or some other native limited resource) before the GC can finish.

Flutter had this problem with images for example - we were relying on the GC to clean them up, which works pretty often but does not work so well when you try to load larger images in memory constrained environments. The more we tried to make the GC clean this up for us, the worse it got - the GC sometimes couldn't work fast enough (so new images could get allocated before the GC-able ones got cleaned up, leading to OOMs), and we also were artificially running the GC too often (Because it saw these huge objects it thought it was responsible for cleaning up). So now we explicitly and eagerly dispose images/graphics resources, and you can't get into that race anymore (and we don't need as many GCs, which are pretty resource intensive to run).

Link: dart-lang/language#1847 (comment)

API doesn't expose runtimeLib

I'm trying to manually call a global function and was expecting to be able to use dart-native's dynamic library runtimeLib. I've realized this is not exposed in the API and am wondering how I would access dart-native's dynamic library as is. My thoughts were DynamicLibrary.open('dart_native.framework/dart_native'); but I'm unsure as to whether I need to manually register a dealloc callback for the dynamic library in this scenario and whether my lib instance and yours would conflict.
below is all the code I'm using to access the global function. I should note, I'm getting syntax errors on this saying "Type given to lookup function must be a valid 'dart.ffi' native function type" despite CFURLRef doing nothing but extending a Struct
class CFURLRef extends Struct{}
It's my understanding Struct is a native type. Any thoughts as to what's going on here?

/// C function `CFURLCreateWithFileSystemPath`.
CFURLRef CFURLCreateWithFileSystemPath(
  CFAllocatorRef arg0,
  CFStringRef arg1,
  CFURLPathStyle arg2,
  bool arg3,
) {
  return _CFURLCreateWithFileSystemPath(arg0, arg1, arg2, arg3);
}

final _CFURLCreateWithFileSystemPath_Dart _CFURLCreateWithFileSystemPath =
    _dynamicLibrary.lookupFunction<_CFURLCreateWithFileSystemPath_C,
        _CFURLCreateWithFileSystemPath_Dart>(
  'CFURLCreateWithFileSystemPath',
);
typedef _CFURLCreateWithFileSystemPath_C = CFURLRef Function(
  CFAllocatorRef arg0,
  CFStringRef arg1,
  CFURLPathStyle arg2,
  bool arg3,
);
typedef _CFURLCreateWithFileSystemPath_Dart = CFURLRef Function(
  CFAllocatorRef arg0,
  CFStringRef arg1,
  CFURLPathStyle arg2,
  bool arg3,
);

provide extended examples and additional doco

I'm considering using dart native however there appears to be only minimal documentation and only trivial examples.

Are you able to provide some extended examples that call common iOS/Android funtions including examples that deal with callbacks and a variety of data types.

I note that there are a number of blogs written in Chinese, English translations of these will enable a far greater audience.

Support API_AVAILABLE

需要支持 API_AVAILABLE
方便 Flutter 调用时兼容不同版本系统的 API
方案需要预研


Update: 仅使用 Annotation 标记,不需要生成代码:

@NativeAvailable(ios: '10.0')
@NativeUnavailable(ios)
@NativeDeprecated(ios: ['10.0', '10.4'])

[documentation] provide benchmark to demostrate statement in readme

your readme states

Replaces the low-performing Flutter channel with faster and more concise code.

I care less about the "concise" part, but your claim that your solution is faster than the first party implementation is interesting
could you provide benchmarks that demonstrate your claim?

Additionally, how does this solution perform against pigeon?

Problems initializing dart native for ios

We have the following unit test in example/test directory of a project:

import "package:test/test.dart";
import 'package:dart_native/dart_native.dart';
void main() {
  // Define the test
  test("Testing ffi implementation of AVAudioPlayer", () {
    runDartNative();
    // Arrange
    NSObject player = new NSObject(Class('NSObject'));
    // Asset
    expect(player.description, '');
  });
}

This is failing with the following error:

Connecting to VM Service at http://127.0.0.1:49354/kOZquTJPEHw=/ws
Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, RegisterDeallocCallback): symbol not found)
dart:ffi                                                      DynamicLibrary.lookup
package:dart_native/src/ios/common/callback_manager.dart      registerDeallocCallback
package:dart_native/…/common/callback_manager.dart:1
package:dart_native/src/ios/common/callback_manager.dart      registerDeallocCallback
package:dart_native/…/common/callback_manager.dart:1
runtimeLib
package:dart_native/…/common/library.dart:17
nativeGetClass
package:dart_native/…/runtime/native_runtime.dart:41
package:dart_native/src/ios/runtime/native_runtime.dart       nativeGetClass
package:dart_native/…/runtime/native_runtime.dart:1
_getClass
package:dart_native/…/runtime/class.dart:64
new Class
package:dart_native/…/runtime/class.dart:16
main.<fn>
test/avaudioplayer_test.dart:9

I should note I've added use_frameworks! to the podspec in the examples directory. Thanks in advance :)

Flutter 单元测试库引用问题

dylib is null, open dyLibrary path + libdart_native.so

Invalid argument(s): Failed to load dynamic library (dlopen(libdart_native.so, 0x0001): tried: '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/./libdart_native.so' (no such file), '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/../../../libdart_native.so' (no such file), '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/Frameworks/libdart_native.so' (no such file), '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/./libdart_native.so' (no such file), '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/../../../libdart_native.so' (no such file), '/Users/civelxu/Library/Application Support/fvm/versions/flutter/bin/cache/artifacts/engine/darwin-x64/Frameworks/libdart_native.so' (no such file), 'libdart_native.so' (no such file), '/usr/local/lib/libdart_native.so' (no such file), '/usr/lib/libdart_native.so' (no such file), '/Users/civelxu/xxx/xxx/xxx/libdart_native.so' (no such file), '/usr/local/lib/libdart_native.so' (no such file), '/usr/lib/libdart_native.so' (no such file))

使用Android结构去运行项目 会报错

Describe the bug
编译器 (1.8.0_242-release) 中出现异常错误。如果在 Bug Database (http://bugs.java.com) 中没有找到该错误, 请通过 Java Bug 报告页 (http://bugreport.java.com) 建立该 Java 编译器 Bug。请在报告中附上您的程序和以下诊断信息。谢谢。
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at com.sun.tools.javac.util.Assert.error(Assert.java:133)
at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:74)
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:94)
at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:55)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:40)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:97)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:46)
at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:36)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompiler.execute(CleaningJavaCompiler.java:53)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory.lambda$createRebuildAllCompiler$0(IncrementalCompilerFactory.java:98)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:61)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:45)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:343)
at org.gradle.api.tasks.compile.JavaCompile.performIncrementalCompilation(JavaCompile.java:237)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:209)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
at org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction.doExecute(IncrementalInputsTaskAction.java:32)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:555)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:540)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:523)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:271)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:260)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:33)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:42)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:159)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:72)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:43)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
at java.util.Optional.orElseGet(Optional.java:267)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:187)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:179)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)

version:0.7.4 or master

The number of arguments for methods dart and objc does not match!

Test ReadMe function Native call Dart:

interface.setMethodCallHandler('totalCost', (double unitCost, int count, List list) async { return {'totalCost: ${unitCost * count}': list}; });

swift
self.invokeMethod("totalCost", arguments: [0.123456789, 10, ["testArray"]]) { result, err in DDLogInfo("invokeMethod totalCost \(result) \(err)") }
always return 'The number of arguments for methods dart and objc does not match!'

请问可以在原生的主线程调用原生函数吗?

大佬好。
我在调用iOS的方法时,方法内部使用了一些UIView,但是报错了,说是不在主线程。
所以想问一下,dart -> native,默认会在非主线程调用吗?怎么样可以让这个调用发生在主线程呢?

【android】native_basic_type.dart定义的long、double类型数据,在安卓仅构建armeabi-v7a架构的包时,传参数据存在转换丢失的情况

问题

native_basic_type定义的long类型数据,在安卓仅构建armeabi-v7a架构的包时,如果long类型数据值大于2147483647(2^31-1),java侧获取的数据存在转换丢失的情况

double类型数据也不太对

具体案例

Dart_Native 版本:0.3.22

flutter环境
Flutter version 1.22.6
Dart version 2.10.5

修改如下几个文件

  • example/android/app/build.gradle
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.dartnative.dart_native_example"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        // 仅armeabi-v7a架构
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
  • example/lib/android/unit_test.dart
  bool resultCall =
  stub.complexCall("test", 2147483647, 'a', 10.0, 12.0, 1, 2, 2147483647, false);
  print('call result:$resultCall');

  resultCall =
      stub.complexCall("test", 2147483648, 'a', 10.0, 12.0, 1, 2, 2147483648, false);
  print('call result:$resultCall');

  resultCall =
      stub.complexCall("test", 4294967295, 'a', 10.0, 12.0, 1, 2, 4294967295, false);
  print('call result:$resultCall');

  resultCall =
  stub.complexCall("test", 4294967296, 'a', 10.0, 12.0, 1, 2, 4294967296, false);
  print('call result:$resultCall');

  resultCall =
  stub.complexCall("test", 42949672960, 'a', 10.0, 12.0, 1, 2, 42949672960, false);
  print('call result:$resultCall');

  • lib/src/android/runtime/jobject.dart
  NativeArguments _parseNativeArguments(List args, {List argsSignature}) {
    Pointer<Pointer<Void>> pointers = nullptr.cast();

    /// extend a bit for string
    Pointer<Pointer<Utf8>> typePointers =
        allocate<Pointer<Utf8>>(count: (args?.length ?? 0) + 1);
    int stringTypeBitmask = 0;
    if (args != null) {
      pointers = allocate<Pointer<Void>>(count: args.length);

      for (var i = 0; i < args.length; i++) {
        var arg = args[i];
        if (arg == null) {
          throw 'One of args list is null';
        }

        Pointer<Utf8> argSignature =
            argsSignature == null || !(argsSignature[i] is Pointer<Utf8>)
                ? null
                : argsSignature[i];

        if (arg is String) {
          stringTypeBitmask |= (0x1 << i);
        }

        storeValueToPointer(arg, pointers.elementAt(i),
            typePtr: typePointers.elementAt(i), argSignature: argSignature);

        //方便打印看save后再load的值
        if (arg is long) {
          int value = pointers.elementAt(i).cast<Int64>().value;
          var loadValue = loadValueFromPointer(pointers.elementAt(i).value, "J", typePtr: typePointers);
          print("DartNative _parseNativeArguments arg=$arg, storeValueToPointer value=$value, loadValueFromPointer value=$loadValue");
        }
      }
    }
    typePointers.elementAt(args?.length ?? 0).value = Utf8.toUtf8("0");
    return NativeArguments(pointers, typePointers, stringTypeBitmask);
  }

打印结果



2021-09-06 22:19:29.891 15223-16988/com.dartnative.dart_native_example I/flutter: DartNative _parseNativeArguments arg=2147483647, storeValueToPointer value=2147483647, loadValueFromPointer value=2147483647
2021-09-06 22:19:29.891 15223-16988/com.dartnative.dart_native_example D/dart_java: tag :test + 2147483647 + a + 2097152.0 + 12.0 + 1 + 2 + 2147483647 + false
2021-09-06 22:19:29.891 15223-16988/com.dartnative.dart_native_example I/flutter: call result:true
2021-09-06 22:19:29.891 15223-16988/com.dartnative.dart_native_example I/flutter: DartNative _parseNativeArguments arg=2147483648, storeValueToPointer value=2147483648, loadValueFromPointer value=2147483648
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example D/dart_java: tag :test + -2147483648 + a + 2097152.0 + 12.0 + 1 + 2 + -2147483648 + false
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: call result:true
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: DartNative _parseNativeArguments arg=4294967295, storeValueToPointer value=4294967295, loadValueFromPointer value=4294967295
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example D/dart_java: tag :test + -1 + a + 2097152.0 + 12.0 + 1 + 2 + -1 + false
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: call result:true
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: DartNative _parseNativeArguments arg=4294967296, storeValueToPointer value=4294967296, loadValueFromPointer value=0
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example D/dart_java: tag :test + 0 + a + 2097152.0 + 12.0 + 1 + 2 + 0 + false
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: call result:true
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example I/flutter: DartNative _parseNativeArguments arg=42949672960, storeValueToPointer value=42949672960, loadValueFromPointer value=0
2021-09-06 22:19:29.892 15223-16988/com.dartnative.dart_native_example D/dart_java: tag :test + 0 + a + 2097152.0 + 12.0 + 1 + 2 + 0 + false

// java long赋值打印结果
2021-09-06 22:34:20.989 16940-19032/com.dartnative.dart_native_example D/dart_java: java long:2147483647 + 2147483648 + 4294967295 + 4294967295 + 4294967296 + 42949672960

directly calling the iOS sdk?

It's it possible to call directly into the iOS native SDK without writing objective C bridging code?

I maintain the sounds package and would like to remove all of the objective C code and replace it with pure dart
.
https://pub.dev/packages/sounds

Is this feasible or will I still need to build a bridging layer to call into the iOS SDK?

The SDK API I'm using also uses call backs, are callbacks support by dart native?

传输的数据有没有大小限制

跑了example遇到了两个问题,使用的是flutter调用getString获取的数据。
1.大于70KB左右的数据会被截断。
2.大于300KB左右循环100次的取值会崩溃。
image

type 'Bool' not found

Describe the bug
../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/darwin/runtime/internal/native_runtime.dart:24:5: Error: Type 'Bool' not found.
Bool returnString,
^^^^
../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/darwin/runtime/internal/native_runtime.dart:110:5: Error: Type 'Bool' not found.
Bool shouldReturnAsync,
^^^^
../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/android/runtime/functions.dart:75:21: Error: 'Bool' isn't a type.
Bool isInterface)>>('InvokeNativeMethod')
^^^^
../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/android/runtime/functions.dart:76:10: Error: Expected type 'NativeFunction<Pointer Function(Pointer, Pointer, Pointer<Pointer>, Pointer<Pointer>, Int32, Pointer, Uint32, Pointer<NativeFunction<Void Function(Pointer, Pointer, Pointer<Pointer>, Int32)>>, Int64, Int32, invalid-type)>' to be a valid and instantiated subtype of 'NativeType'.

  • 'NativeFunction' is from 'dart:ffi'.
  • 'Pointer' is from 'dart:ffi'.
  • 'Void' is from 'dart:ffi'.
  • 'Utf8' is from 'package:ffi/src/utf8.dart' ('../../.pub-cache/hosted/pub.flutter-io.cn/ffi-1.2.1/lib/src/utf8.dart').
  • 'Int32' is from 'dart:ffi'.
  • 'Uint32' is from 'dart:ffi'.
  • 'Int64' is from 'dart:ffi'.
    .asFunction();
    ^
    ../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/darwin/runtime/internal/native_runtime.dart:35:17: Error: Expected type 'NativeFunction<Int32 Function(Pointer, Pointer, Pointer, invalid-type, Pointer<NativeFunction<Void Function(Pointer<Pointer<Pointer>>, Pointer<Pointer>, Int32, Pointer<Pointer>, Int32)>>, Int64)>' to be a valid and instantiated subtype of 'NativeType'.
  • 'NativeFunction' is from 'dart:ffi'.
  • 'Int32' is from 'dart:ffi'.
  • 'Pointer' is from 'dart:ffi'.
  • 'Void' is from 'dart:ffi'.
  • 'Utf8' is from 'package:ffi/src/utf8.dart' ('../../.pub-cache/hosted/pub.flutter-io.cn/ffi-1.2.1/lib/src/utf8.dart').
  • 'Int64' is from 'dart:ffi'.
    nativeDylib.lookupFunction<AddMethodC, AddMethodD>('native_add_method');
    ^
    ../../.pub-cache/hosted/pub.flutter-io.cn/dart_native-0.7.3/lib/src/darwin/runtime/internal/native_runtime.dart:118:6: Error: Expected type 'NativeFunction<Pointer Function(Pointer, Pointer<NativeFunction<Void Function(Pointer<Pointer<Pointer>>, Pointer<Pointer>, Int32, Int32, Int64)>>, invalid-type, Int64)>' to be a valid and instantiated subtype of 'NativeType'.
  • 'NativeFunction' is from 'dart:ffi'.
  • 'Pointer' is from 'dart:ffi'.
  • 'Void' is from 'dart:ffi'.
  • 'Utf8' is from 'package:ffi/src/utf8.dart' ('../../.pub-cache/hosted/pub.flutter-io.cn/ffi-1.2.1/lib/src/utf8.dart').
  • 'Int32' is from 'dart:ffi'.
  • 'Int64' is from 'dart:ffi'.
    .lookupFunction<BlockCreateC, BlockCreateD>('native_block_create');
    ^

To Reproduce
Steps to reproduce the behavior:

  1. dart_native: 0.7.3
  2. flutter:2.5.3
  3. dart:2.14.4

某些字符串从iOS返回dart会报错

Flutter version 2.10.4
dart_native: ^0.6.3

发现在iOS下(安卓不会),返回某些字符串会报错,比如"鎮",我把example里的示例改动了一下:

  • (NSString *)fooNSString:(NSString *)str {
    // DDLogInfo(@"%s arg: %@", FUNCTION, str);
    return @"鎮";
    }

发现报错了,真机模拟器都如此。

用codegen生成dart代码报错,请问该怎么操作啊

Error: Cannot find module '/Users/zz/adult_flutter/lib/objc/DNObjectiveCConverter.js

at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at MessagePort. (node:internal/main/worker_thread:179:24)
at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:459:20)
at MessagePort.exports.emitMessage (node:internal/per_context/messageport:18:26) {
code: 'MODULE_NOT_FOUND',
requireStack: []

成员变量 类方法无法使用

oc:

@interface RuntimeSon : RuntimeStub
@property (nonatomic,copy) NSString *test;

+ (instancetype)init2;
@end

codegen生成的代码

import 'dart:ffi';

import 'package:dart_native/dart_native.dart';
import 'package:dart_native_gen/dart_native_gen.dart';
import 'runtimestub.dart';

@native
class RuntimeSon extends RuntimeStub {
  RuntimeSon([Class isa]) : super(Class('RuntimeSon'));

  String get test => perform('test'.toSEL());

  set test(String test) => perform('setTest:'.toSEL(), args: [test]);

  static RuntimeSon init2() {
    return Class('RuntimeSon').perform('init2'.toSEL(), args: []);
  }
}

dart:

  _clickMe() {
    var test = RuntimeSon();
    test.test = 'asdfafs';
  }

  _clickMeInit() {
    var test = RuntimeSon.init2();
    print(test);
  }

第一个报错

flutter: Another exception was thrown: signature for [Pointer<Void>: address=0x60000241d070 setTest:] is NULL.

第二个报错

flutter: Another exception was thrown: type 'NSObject' is not a subtype of type 'RuntimeSon'

How to use dart native for swift?

I noticed dart native has used runtime of Objective-C(not sure), but swift is more popular now.

The dart native market needs a lot of components and using swift to write compoents is a good way.

This is my personal opinion. Thx.

x86虚拟机运行调用异步消息报错

D/CallbackHandler(32439): invoke method: callbackComplex
E/_native_exampl(32439): JNI ERROR (app bug): accessed stale Local 0xc9 (index 12 in a table of size 11)
F/_native_exampl(32439): java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: use of deleted local reference 0xc9
F/_native_exampl(32439): java_vm_ext.cc:577] from java.lang.Object com.dartnative.dart_native.CallbackInvocationHandler.hookCallback(long, java.lang.String, int, java.lang.String[], java.lang.Object[], java.lang.String)
F/_native_exampl(32439): runtime.cc:655] Runtime aborting...
F/_native_exampl(32439): runtime.cc:655] Dumping all threads without mutator lock held
F/_native_exampl(32439): runtime.cc:655] All threads:
F/_native_exampl(32439): runtime.cc:655] DALVIK THREADS (19):
F/_native_exampl(32439): runtime.cc:655] "main" prio=10 tid=1 Runnable

android 工程测试代码跑不过,会报错

错误方法在unit_test.dart文件的

  Map map = stub.getMap({"1": 10, "2": 20, "3": 30});
  map.forEach((key, value) {
    print("map from native $key : $value");
  });

这块代码

错误日志

2021-08-19 17:28:51.109 30499-30533/com.dartnative.dart_native_example E/_native_exampl: JNI ERROR (app bug): attempt to pass an instance of java.util.HashMap$KeySet as argument 1 to java.util.List com.dartnative.dart_native.ArrayListConverter.setToList(java.util.HashSet)
2021-08-19 17:28:51.109 30499-30533/com.dartnative.dart_native_example A/_native_exampl: java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: bad arguments passed to java.util.List com.dartnative.dart_native.ArrayListConverter.setToList(java.util.HashSet) (see above for details)
2021-08-19 17:28:51.157 30499-30533/com.dartnative.dart_native_example A/_native_exampl: runtime.cc:655] Runtime aborting...
    runtime.cc:655] Dumping all threads without mutator lock held
    runtime.cc:655] All threads:
    runtime.cc:655] DALVIK THREADS (20):
    runtime.cc:655] "Thread-3" prio=6 tid=26 Runnable
    runtime.cc:655]   | group="" sCount=0 dsCount=0 flags=0 obj=0x131c0dc8 self=0x77208ef400
    runtime.cc:655]   | sysTid=30533 nice=-1 cgrp=top-app sched=0/0 handle=0x7788795cc0
    runtime.cc:655]   | state=R schedstat=( 1180773104 13527663 132 ) utm=87 stm=30 core=7 HZ=100
    runtime.cc:655]   | stack=0x778869e000-0x77886a0000 stackSize=995KB
    runtime.cc:655]   | held mutexes= "abort lock" "mutator lock"(shared held)
    runtime.cc:655]   native: #00 pc 000000000049fed8  /apex/com.android.art/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
    runtime.cc:655]   native: #01 pc 00000000005ace00  /apex/com.android.art/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+376)
    runtime.cc:655]   native: #02 pc 00000000005c9f38  /apex/com.android.art/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+924)
    runtime.cc:655]   native: #03 pc 00000000005c3e78  /apex/com.android.art/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+528)
    runtime.cc:655]   native: #04 pc 00000000005c3044  /apex/com.android.art/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)+1920)

Async callback by ffi

DartNative async callback is running under flutter channel now, which has to receive a async result callback. It needs block current thread and waiting for return value. Callback on main thread can NOT be blocked.

Solution&Plan:

  1. Replace Flutter channel by ffi/port.
  2. Waiting for stable channel.
  3. Waiting for official wrapper.

ref: dart-lang/sdk#37022

consider using SWIG for parsing objective-c

Just wondering if you have looked at SWIG for generating the bindings.

http://swig.org/

My understanding is that SWIG parses C and Objective-C headers and generates an intermediate representation.

From this I would guess that you could then generate the dart bindings.

iOS 调用含有异步block的方法会崩

dart_native was compiled with optimization - stepping may behave oddly; variables may not be available.
OC

+ (void)test:(void (^)())t {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (t) {
            t();
        }
    });
}

dart

A.test(() {
print('hello');
});

Documentation

  • iOS documentation.
  • Android documentation.
  • Readme&Wiki(examples)

Related issue:
#29

Android 莫名其妙偶现崩溃

接入这个后,偶尔出现崩溃,下面是日志,请问能看出是什么原因吗

2022-01-06 13:39:03.723 28751-28751/com.addcn.android.house591 E/libprocessgroup: set_timerslack_ns write failed: Operation not permitted
2022-01-06 13:39:03.972 6721-27866/? E/MiuiFastConnectService: check adv data not fast connect
2022-01-06 13:39:04.031 28751-12801/com.addcn.android.house591 A/libc: fdsan: attempted to close file descriptor 125, expected to be unowned, actually owned by SocketImpl 0x759c69f
2022-01-06 13:39:04.384 6721-27866/? E/MiuiFastConnectService: check adv data not fast connect
2022-01-06 13:39:04.436 12939-12939/? E/chromium: [0106/133904.436127:ERROR:elf_dynamic_array_reader.h(64)] tag not found
2022-01-06 13:39:04.456 28751-12801/com.addcn.android.house591 A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 12801 (OkHttp Connecti), pid 28751 (ndroid.house591)
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: Build fingerprint: 'Xiaomi/mars/mars:11/RKQ1.201112.002/V12.5.20.0.RKACNXM:user/release-keys'
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: Revision: '0'
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: ABI: 'arm64'
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: Timestamp: 2022-01-06 13:39:04+0800
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: pid: 28751, tid: 12801, name: OkHttp Connecti  >>> com.addcn.android.house591 <<<
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: uid: 10352
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG: Abort message: 'fdsan: attempted to close file descriptor 125, expected to be unowned, actually owned by SocketImpl 0x759c69f'
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x0  0000000000000000  x1  0000000000003201  x2  0000000000000006  x3  000000710bad99f0
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x4  0000000000000000  x5  0000000000000000  x6  0000000000000000  x7  0000000000000030
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x8  00000000000000f0  x9  7a005ffe29fc8c48  x10 0000000000000001  x11 0000000000000000
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x12 0000000000000028  x13 0000034b422f43b8  x14 00019196fc3131f5  x15 0000000034155555
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x16 0000007208ecb948  x17 0000007208eaa350  x18 00000070e5e54000  x19 000000000000704f
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x20 0000000000003201  x21 000000710badf000  x22 000000720c8eab5c  x23 0000000000000003
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x24 000000710bad9ae0  x25 ffffff80ffffffc8  x26 000000710bad9760  x27 000000710bad9720
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     x28 000000710bad9bc0  x29 000000710bad9a80
2022-01-06 13:39:04.673 12949-12949/? A/DEBUG:     lr  0000007208e61f0c  sp  000000710bad96a0  pc  0000007208e61f2c  pst 0000000000001000
2022-01-06 13:39:04.765 28751-28751/com.addcn.android.house591 E/libprocessgroup: set_timerslack_ns write failed: Operation not permitted
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG: backtrace:
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #00 pc 000000000008df2c  /apex/com.android.runtime/lib64/bionic/libc.so (fdsan_error(char const*, ...)+588) (BuildId: 5f57d25b37c043ed36c0e4147dcc8b3f)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #01 pc 000000000008dc28  /apex/com.android.runtime/lib64/bionic/libc.so (android_fdsan_close_with_tag+740) (BuildId: 5f57d25b37c043ed36c0e4147dcc8b3f)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #02 pc 000000000008e390  /apex/com.android.runtime/lib64/bionic/libc.so (close+16) (BuildId: 5f57d25b37c043ed36c0e4147dcc8b3f)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #03 pc 00000000000362c0  /apex/com.android.conscrypt/lib64/libjavacrypto.so (NativeCrypto_SSL_free(_JNIEnv*, _jclass*, long, _jobject*)+124) (BuildId: fd088ae72990178e580d5ab157316338)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #04 pc 000000000013ced4  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #05 pc 00000000001337e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #06 pc 00000000001a8a94  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #07 pc 0000000000319390  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #08 pc 000000000030f6bc  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #09 pc 000000000014a0c8  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+33960) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #10 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #11 pc 0000000000023634  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.NativeSsl.close)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #12 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #13 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #14 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #15 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #16 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #17 pc 000000000001a08c  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngine.closeAndFreeResources)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #18 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #19 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #20 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #21 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #22 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #23 pc 000000000001a22c  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngine.freeIfDone)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #24 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #25 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #26 pc 0000000000310760  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+668) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #27 pc 000000000014894c  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+27948) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #28 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #29 pc 00000000000195c0  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngine.wrap)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #30 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #31 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #32 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #33 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #34 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #35 pc 0000000000240450  /apex/com.android.art/javalib/core-oj.jar (javax.net.ssl.SSLEngine.wrap)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #36 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #37 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #38 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #39 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #40 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #41 pc 0000000000019564  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngine.wrap)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #42 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #43 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #44 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #45 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #46 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #47 pc 000000000001725c  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.writeInternal)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #48 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #49 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #50 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #51 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #52 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #53 pc 00000000000170a8  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.access$200)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #54 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #55 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #56 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #57 pc 000000000014a0c8  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+33960) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #58 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #59 pc 0000000000017ce8  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngineSocket.drainOutgoingQueue)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #60 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #61 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #62 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #63 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #64 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #65 pc 0000000000017ac0  /apex/com.android.conscrypt/javalib/conscrypt.jar (com.android.org.conscrypt.ConscryptEngineSocket.close)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #66 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #67 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #68 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #69 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #70 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #71 pc 0000000000020ec4  /apex/com.android.art/javalib/okhttp.jar (com.android.okhttp.internal.Util.closeQuietly)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #72 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #73 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #74 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #75 pc 000000000014a0c8  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+33960) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #76 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #77 pc 00000000000156d4  /apex/com.android.art/javalib/okhttp.jar (com.android.okhttp.ConnectionPool.cleanup)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #78 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #79 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #80 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #81 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #82 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #83 pc 000000000001539c  /apex/com.android.art/javalib/okhttp.jar (com.android.okhttp.ConnectionPool$1.run)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #84 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #85 pc 000000000066c054  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #86 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.883 12949-12949/? A/DEBUG:       #87 pc 00000000021eb2e4  /memfd:jit-cache (deleted) (offset 0x2000000) (java.util.concurrent.ThreadPoolExecutor.runWorker+388)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #88 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #89 pc 00000000001a8a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #90 pc 0000000000319390  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #91 pc 000000000030f6bc  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #92 pc 00000000001489d0  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+28080) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #93 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #94 pc 00000000001f8df8  /apex/com.android.art/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor$Worker.run)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #95 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #96 pc 000000000030eca8  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #97 pc 000000000030f6a0  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #98 pc 000000000014846c  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false, false>(art::interpreter::SwitchImplContext*)+26700) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #99 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #100 pc 00000000000eb838  /apex/com.android.art/javalib/core-oj.jar (java.lang.Thread.run)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #101 pc 0000000000306dc0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.11487796752256266877)+532) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #102 pc 000000000066c054  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #103 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #104 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #105 pc 00000000001a8a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #106 pc 0000000000555ac4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #107 pc 00000000005a4e60  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308) (BuildId: 5b103c304a50c13c7fbeaacc0e0df496)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #108 pc 00000000000eb828  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 5f57d25b37c043ed36c0e4147dcc8b3f)
2022-01-06 13:39:04.884 12949-12949/? A/DEBUG:       #109 pc 000000000008ba48  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 5f57d25b37c043ed36c0e4147dcc8b3f)

dart调用安卓原生方法失败

你好,我们flutter module和原生是同一级目录依赖的,然后flutter需要调用原生的方法
dart代码
@native(javaClass : "com/addcn/android/flutterservice/TWInfoService") class AndroidAppInfoService extends JObject{ ... }
@nativeRoot @pragma('vm:entry-point') void main() { DartNative.init(); runTw591FlutterModules();//类型example的runDartNativeExample()方法 runApp(const MyApp()); }
可是当调用AndroidAppInfoService的时候闪退,请问是因为项目在同一级导致的路径不对吗?请问要怎么改呢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.