-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wasm] cannot load assets by mono_download_assets at out of AppBundle #69259
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionSummary: Cannot initialize dotnet runtime except at location In the template, we can run the sample code by executing the following command in the directory where the assets exist after the build (AppBundle). $ node main.cjs Then, from one directory up, run main.cjs in the following way to cause I expected to find const createDotnetRuntime = require("./dotnet.js");
const { resolve } = require("path");
async function main() {
const { MONO } = await createDotnetRuntime({
configSrc: resolve(__dirname, "mono-config.json"),
});
const app_args = process.argv.slice(2);
await MONO.mono_run_main_and_exit("console.dll", app_args);
}
main(); But an error Reproduction Steps
Snippet1 const createDotnetRuntime = require("./dotnet.js");
const { resolve } = require("path");
async function main() {
const { MONO } = await createDotnetRuntime({
configSrc: resolve(__dirname, "mono-config.json"),
});
const app_args = process.argv.slice(2);
await MONO.mono_run_main_and_exit("console.dll", app_args);
}
main(); Expected behaviorWhen initializing the dotnet runtime, it is possible to load assets other than assembly and resource even if the node runtime path is not the same path. see: runtime/src/mono/wasm/runtime/startup.ts Lines 511 to 520 in 51d51c1
Actual behaviorOnly assembly can be resolved by path and cannot load vfs behavior file. Regression?No response Known WorkaroundsNo response Configuration
Other information
I think we can run runtime/src/mono/wasm/runtime/startup.ts Lines 511 to 520 in 51d51c1
|
PR would be welcome. Note that @radical perhaps your redesign of the bootstrap could consider this request. |
Use localeFile to resolve path for assets outside of remoteSources, so that we can run from a different path than locate that dotnet.js exists ref: dotnet#69259
…changes Squashed commit of the following: commit 8dd23f8 Merge: ffe4a2a 3ac1629 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jul 12 02:13:41 2022 +0900 Merge branch 'main' into resolve-asset-path-by-locatefile commit ffe4a2a Merge: 357ca53 32d0360 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jul 5 01:50:45 2022 +0900 Merge branch 'main' into resolve-asset-path-by-locatefile commit 357ca53 Author: yamachu <yamachu.dev@gmail.com> Date: Fri Jul 1 02:24:48 2022 +0900 If an absolute path is passed to configSrc, do not use locateFile to resolve the path, but fetch the path as is. commit cf45c0d Merge: 527ad98 85223ce Author: yamachu <yamachu.dev@gmail.com> Date: Fri Jul 1 01:16:11 2022 +0900 Merge branch 'main' into resolve-asset-path-by-locatefile commit 527ad98 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 16:58:28 2022 +0900 Remove toAbsoluteUrl from test code commit c339a1a Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 16:58:10 2022 +0900 Ported toAbsoluteUrl in the web environment to pre-module commit 3b4f3f1 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 14:18:16 2022 +0900 Remove unused variable commit 2cdd2c7 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 14:14:54 2022 +0900 Unassign toAbsoluteUrl to use locateFile to correct script directory in Node and V8 environments commit e7a473a Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 14:13:05 2022 +0900 Assign a locateFile to the Module that corrects the prefix Fix that prefix argument does not indicate the location where the script exists when dotnet.wasm is loaded commit d54b143 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 14:05:06 2022 +0900 Remove flags that is only used in certain scenarios commit 71c1ff7 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 03:35:26 2022 +0900 Refactor: use already implemented attributes commit 86227f1 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 02:03:20 2022 +0900 Add notes commit bac891e Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 00:30:42 2022 +0900 test all RunHost The project format changes depending on the host, so projects with the same id cannot be used interchangeably. Therefore, the project is re-created so that the test id changes, and the cache is also discarded. commit f41fd42 Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 00:29:53 2022 +0900 Modified runtime to get the path starting from dotnet.js in shell environment and use that path in test commit 3e2476c Author: yamachu <yamachu.dev@gmail.com> Date: Tue Jun 28 00:25:02 2022 +0900 "--run" prefix is reserved, so change flag name commit ee820c5 Merge: 3076801 c9f80fd Author: yamachu <yamachu.dev@gmail.com> Date: Mon Jun 27 09:43:29 2022 +0900 Merge branch 'main' into resolve-asset-path-by-locatefile commit 3076801 Merge: 8388525 cca6bb6 Author: yamachu <yamachu.dev@gmail.com> Date: Thu Jun 9 21:38:08 2022 +0900 Merge branch 'main' into resolve-asset-path-by-locatefile commit 8388525 Author: yamachu <yamachu.dev@gmail.com> Date: Thu May 26 03:34:56 2022 +0900 Also use locateFile to resolve configFile paths commit 97b2991 Author: yamachu <yamachu.dev@gmail.com> Date: Sat May 21 22:47:57 2022 +0900 Add Unit test to run WasmApp outside of AppBundle directory V8: Could not determine scriptDirectory (always empty string). You must explicitly specify the base path within locateFile. Chrome: Failed to load dotnet.wasm commit a1c3c7a Author: yamachu <yamachu.dev@gmail.com> Date: Wed May 18 00:57:26 2022 +0900 Use localeFile to resolve path for assets outside of remoteSources Use localeFile to resolve path for assets outside of remoteSources, so that we can run from a different path than locate that dotnet.js exists ref: dotnet#69259
Fixed by #72275 |
Description
Summary: Cannot initialize dotnet runtime except at location
AppBundle
directory.In the template, we can run the sample code by executing the following command in the directory where the assets exist after the build (AppBundle).
https://github.com/dotnet/runtime/tree/51d51c1a6631b205b6ace381bbfd417b5c0e481d/src/mono/wasm/templates/templates/console
Then, from one directory up, run main.cjs in the following way to cause
Failed to load config file ./mono-config.json Error: ENOENT: no such file or directory, open './mono-config.json'
I expected to find
mono-config.json
in the same path as the execution path, so I explicitly specified the path and it was successfully loaded.The modified code is as follows...
But an error
MONO_WASM: Error in mono_download_assets: Error: MONO_WASM: Fetch 'supportFiles/0_runtimeconfig.bin' for supportFiles/0_runtimeconfig.bin failed undefined undefined
occurred.Reproduction Steps
Snippet1
Expected behavior
When initializing the dotnet runtime, it is possible to load assets other than assembly and resource even if the node runtime path is not the same path.
see:
runtime/src/mono/wasm/runtime/startup.ts
Lines 511 to 520 in 51d51c1
Actual behavior
Only assembly can be resolved by path and cannot load vfs behavior file.
Regression?
No response
Known Workarounds
No response
Configuration
Other information
I think we can run
locateFile
on any file type, but what is the reason for narrowing down the types?runtime/src/mono/wasm/runtime/startup.ts
Lines 511 to 520 in 51d51c1
The text was updated successfully, but these errors were encountered: