I'm trying to use V8 library compiled via vcpkg install v8 but receiving the following error:
Failed to deserialize the V8 snapshot blob. This can mean that the snapshot blob file is corrupted or missing.
I'm testing it on shipped hello-world.cc example:
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
Isolate* isolate = Isolate::New(create_params); // << here is the crash
Isolate::Scope isolate_scope(isolate);
This error is generated in Isolate* isolate = Isolate::New(create_params); because inner variable i_isole doesn't have assigned any snapshot_blog:
if (!i::Snapshot::Initialize(i_isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
if (i_isolate->snapshot_blob() != nullptr) {
FATAL(
"Failed to deserialize the V8 snapshot blob. This can mean that the "
"snapshot blob file is corrupted or missing.");
}
Unfortunately, I'm not able to find any reference to this error. Thanks for any advice.
Updated: I'm trying it on Visual Studio 2019, the same on 32-bit build and 64-bit build too.
Updated: Based on vcpkg.json file, the version is "9.0.257.17". I will try to update it to the latest version if this is not some already fixed bug.
For v8::V8::InitializeExternalStartupData(argv[0]); to work, make sure you have the file snapshot_blob.bin in the same directory as the executable you've compiled. Alternatively, make sure you're passing the correct path instead of argv[0].
I don't know anything about vcpkg install v8; it could be that the library you get that way is compiled without V8_USE_EXTERNAL_STARTUP_DATA, in which case you should turn off external startup data for your build as well. If you don't have a snapshot_blob.bin file at all, that would be an indicator that this is the case.
Related
I have to decode BIN file downloaded from a company server to .txt or JSON File format using protocol buffer/compiler (which I have installed). I am using the following decode command in VS Code terminal for the purpose but do not able to deduce the error. I am an automotive systems engineer with no knowledge of coding language and have to decode the BIN file to complete my graduation thesis, so any help will be great full.
Windows Powershell error:
PS C:\Users\user\Desktop\MyPrograms> C:\protoc-3.14.0-win64\bin\protoc --decode=se.niradynamics.ncs.protobuf.output.RoadLayerTile roadlayertile.proto "< road_roughness_aggregation_23602633.bin >" output.txt
Could not make proto path relative: < road_roughness_aggregation_23602633.bin >: No such file or directory
It's just that it can't find the bin file, you have to search for it with the Windows file manager.
You should not have quotes around the pipe ( < and > ) operations, otherwise instead of redirecting stdin / stdout, you are looking for the literal file with > and < in the path, which isn't a thing that can exist. Take away the double quotes entirely.
To be honest though: using protoc here is very much doing this the hard way. If this was me, I'd run the .proto through either protoc or protogen to get a code model that represents the schema in my language of choice, and deserialize into that, then run that model through any JSON serializer.
I am trying to make a Rust WebAssembly project and have modified the rust-webpack-template as my starting point. The template is a webpack project with a JavaScript file that calls a single Wasm function and the Rust Wasm takes over from there.
I have modified the template because I would like to have my main logic in JavaScript and call the Rust Wasm through an API.
I have changed the webpack entry to bootstrap.js shown below.
// bootstrap.js
import("./index.js").catch(e =>
console.error("Error importing 'index.js':", e)
);
I added the file index.js and it calls the Rust Wasm functions
// index.js
import * as wasm from "../crate/pkg/rust_webpack";
const title = document.getElementById("msg");
title.innerText = wasm.get_msg();
The get_msg function from Rust looks like this:
#[wasm_bindgen]
pub fn get_msg() -> String {
"Hello from Rust WebAssembly!".to_owned()
}
When I run the project using webpack-dev-server -d, everything works fine.
However, when I build the project using webpack and try and host the generated files directly, nothing is displayed and the browser console displays the error:
Error importing 'index.js': TypeError: "Response has unsupported MIME type"
This error comes from the code in bootstrap.js but I'm not entirely sure what it means or how to fix this error.
Why do things work when serving with the webpack dev server but not after bundling everything together?
As Shepmaster helped me to figure out in the comments, the MIME type of the .wasm file is being set to application/octet-stream when the browser expects it to be application/wasm.
I am using a simple express server to host my files. Express can be configured to use the correct MIME type with a single line.
var express = require('express');
var app = express();
// Set the MIME type explicitly
express.static.mime.define({'application/wasm': ['wasm']});
app.use(express.static('./dist'));
app.listen(3000);
According to this issue, express will handle .wasm files correctly after version 4.17. It works correctly in webpack dev server because they implemented their own workaround while they wait for the fix in express.
I had a similar problem ("Response has unsupported MIME type") with Flask. The problem was that I didn't have a separate route to the .wasm file. For example:
#app.route('/path/to/file.wasm')
def wasm_file():
return send_file('/path/to/file.wasm', mimetype = 'application/wasm');
It is not the answer to this question, but it's a hint for other people who have a similar problem.
I also encountered this problem, leading me to change my .htaccess file (I'm using Apache to host my local server) to include the following:
AddType application/wasm wasm
If the error persists, and you are getting this error from using WebAssembly.instantiateStreaming, this related question may have an explanation and workaround: WebAssembly InstantiateStreaming Wrong MIME type
I'm having difficulties.
I am implementing logic to read the file, encodes it, and send it to the server.
Currently, the library used as javascript interpreter is using 'otto'.
I imported 'fs'(I know it is Built-in module) like
var fs = require("fs");
fs.readFileSync('./test.txt', 'utf8');
but occurred error Module not found: Error: Can't resolve 'fs'
So I inserted node: { fs: "empty" } in webpack.config.js file.
Then compile error is not occurred. But when I called a function that contains fs.readFileSync using cli, occurred error.
TypeError: 'readFileSync' is not a function
First question:
I know that 'otto' is just javascript interpreter. For this reason, when I imported 'fs', is there a failure to find the module?
Second question:
If not, How can I read a file from the clientside and send it to the server?
Last question: Using 'otto', It is impossible??
This is my spec.
macOS High Sierra, Webpack 4.9.1, Node.js 8.11.1.
How to read a file in client side
Since you mention Webpack, I'm assuming the "client side" here is a browser. To read a file from a browser, you use the File API. Note that your code cannot specify what file to read; the user does that, either by picking a file in an input type="file" element, or dragging a file into a drop area. In both cases, you'll get a File object, which you can read using the File API.
You cannot use the fs Node.js module in a browser.
I want to build an app with javascript which integrates object-detection. For this, I wanna use the ssd_mobilenet_v1_coco model and use it in tensorflow.
However this line of code:
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' \saved_model\saved_model \saved_model\web_model
does not work. It gives me file not found error, but the file is actually there unless I'm very dump and turned back into computer beginner.
OSError: SavedModel file does not exist at: \saved_model\saved_model
Also, I'm not quite sure about the output node names but this is secondary.
Thanks for support, hopefully I'm not totally dump :)
This might be because you are using an absolute path instead of a relative path.
On mac or linux, if you are in the directory that contains the downloaded unzipped model, you would run a command of that type :
tensorflowjs_converter --input_format=tf_saved_model --output_node_names='detection_boxes,detection_classes,detection_scores,num_detections' --saved_model_tags=serve ./ssd_mobilenet_v1_coco/saved_model ./ssd_mobilenet_v1_coco/web_model
From what i can see you are on Windows.
If you are running your command from the directory that contains the saved_model folder, you should run the following command :
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' .\saved_model\saved_model .\saved_model\web_model
I have a node.js (v0.6.12) application that starts by evaluating a Javascript file, startup.js. It takes a long time to evaluate startup.js, and I'd like to 'bake it in' to a custom build of Node if possible.
The v8 source directory distributed with Node, node/deps/v8/src, contains a SconScript that can almost be used to do this. On line 302, we have
LIBRARY_FILES = '''
runtime.js
v8natives.js
array.js
string.js
uri.js
math.js
messages.js
apinatives.js
date.js
regexp.js
json.js
liveedit-debugger.js
mirror-debugger.js
debug-debugger.js
'''.split()
Those javascript files are present in the same directory. Something in the build process apparently evaluates them, takes a snapshot of state, and saves it as a byte string in node/out/Release/obj/release/snapshot.cc (on Mac OS). This file seems to be baked into Node.
Some customization of the startup snapshot is possible by altering the SconScript. For example, I can change the definition of the builtin Date.toString by altering date.js. I can even add new global variables by adding startup.js to the list of library files, with contents global.test = 1.
However, I can't put just any javascript code in startup.js. If it contains Date.toString = 1;, an error results even though the code is valid at the node repl:
Build failed: -> task failed (err #2):
{task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1
And it obviously can't make use of code that depends on libraries Node adds to v8. global.underscore = require('underscore'); causes the same error.
I'd ideally like a tool, customSnapshot, where customSnapshot startup.js evaluates startup.js with Node and then dumps a snapshot to a file, snapshot.cc, which I can put into the Node source directory. I can then build node and tell it not to rebuild the snapshot.
I just added an option to the mksnapshot command (which runs while you are building V8). The new --extra-file=filename.js flag lets you specify a file that is to be loaded and run in the process and then put in the snapshot. It's on the trunk version of V8, not the 3.11 branch that is being used for node 0.8 so you will have to run node 0.8 with V8 version 3.11. As far as I know at the moment that works, but you will be somewhat on your own.
Please file bugs if you try this and it doesn't work for you.