เมื่อ วันพุธที่ 15 มกราคม ค.ศ. 2020 15 นาฬิกา 15 นาที 49 วินาที UTC+7, 
Darin Dimitrov เขียนว่า:
>
> I have embedded V8 (7.8.279.19) inside my Android application and tried 
> executing a script that compiles a WebAssembly module.
>
> Unfortunately the promise returned by the "WebAssembly.compile" method is 
> never completed (neither the "then" or the "catch" methods are invoked). 
> The same happens with the "WebAssembly.instantiate" method:
>
> std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform
> ();
> v8::V8::InitializePlatform(platform.get());
> v8::V8::Initialize();
>
> v8::Isolate::CreateParams create_params;
> create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::
> NewDefaultAllocator();
> v8::Isolate* isolate = v8::Isolate::New(create_params);
> v8::Isolate::Scope isolate_scope(isolate);
> v8::HandleScope scope(isolate);
> auto global_template = v8::ObjectTemplate::New(isolate);
> global_template->Set(v8::String::NewFromUtf8(isolate, "log", v8::
> NewStringType::kNormal).ToLocalChecked(), v8::FunctionTemplate::New(
> isolate, [](const v8::FunctionCallbackInfo<v8::Value>& info) {
>     v8::Isolate* isolate = info.GetIsolate();
>     v8::String::Utf8Value utf(isolate, info[0].As<v8::String>());
>     __android_log_print(ANDROID_LOG_DEBUG, "V8Native", "%s",*utf);
> }));
>
> v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr, 
> global_template);
> v8::Context::Scope context_scope(context);
> const char* csource = R"(
>     let bytes = new Uint8Array([
>         0,97,115,109,1,0,0,0,1,8,2,96,1,127,0,96,0,0,2,8,1,2,106,
>         115,1,95,0,0,3,2,1,1,8,1,1,10,9,1,7,0,65,185,10,16,0,11
>     ]);
>     log('before the call');
>     WebAssembly
>         .instantiate(bytes)
>         .then(obj => log('success'))
>         .catch(err => log('log'));
>     )";
> v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, csource, 
> v8::NewStringType::kNormal).ToLocalChecked();
> v8::Local<v8::Script> script = v8::Script::Compile(context, source).
> ToLocalChecked();
> v8::Local<v8::Value> result;
> script->Run(context).ToLocal(&result);
>
>
>
> Do you have any idea what I might be missing here? The same javascript code 
> works fine in the desktop browser.
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/d128a027-4a09-4aa0-9486-a308d9bd303c%40googlegroups.com.

Reply via email to