为了账号安全,请及时绑定邮箱和手机立即绑定

WebAssembly.instantiate 没有调用 then 也没有在嵌入的 v8 中捕获

WebAssembly.instantiate 没有调用 then 也没有在嵌入的 v8 中捕获

GCT1015 2021-06-16 10:06:28
我试图v8 7.2为我的 Android 项目提供WebAssembly 功能。我已成功导入v8为静态库。但是我遇到了 WebAssembly 既没有调用也then没有catch回调的问题。这是我的代码如下:std::unique_ptr<v8::Platform> platform;v8::Isolate *isolate;v8::Persistent<v8::Context> persistentContext;void runMain();void runScript();void _log(const v8::FunctionCallbackInfo<v8::Value>& info) {  v8::String::Utf8Value utf(isolate, info[0].As<v8::String>());  __android_log_print(ANDROID_LOG_DEBUG, "V8Native", "%s",*utf);}void JNICALLJava_com_hustunique_v8demoapplication_MainActivity_initV8(JNIEnv *env, jobject /* this */) {  // Initialize V8.  v8::V8::InitializeICU();  platform = v8::platform::NewDefaultPlatform();  v8::V8::InitializePlatform(&(*platform.get()));  v8::V8::Initialize();  runMain();}void runMain() {  // Create a new Isolate and make it the current one.  v8::Isolate::CreateParams create_params;  create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();  isolate = v8::Isolate::New(create_params);//  isolate->Enter();  v8::Isolate::Scope isolate_scope(isolate);  v8::HandleScope scope(isolate);在上面的演示中,我得到了Called from WebAssembly Hello world例外的输出,但我无法获得错误消息和实例信息。我在网站上做了一个简单的例子,与上面的演示进行比较,这是网站中的输出,我认为可以轻松复制:Called from WebAssembly Hello worldCalled with error LinkError: WebAssembly.instantiate(): Import #0 module="js" function="_" error: function import requires a callable似乎在我的演示中,既没有resolve也没有reject从 WebAssembly 的返回承诺中调用。在检查了v8::Local<v8::Value> resultinrunScript方法的类型后,v8 运行时确认它是一个 promise 对象。此代码段也不起作用,此外,它停留在kPending状态。我搜索了类似的东西flush the promise queue,但没有得到任何解决方案。我在这里缺少什么?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 270 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信