Skip to content

wasm broken: panicked at 'called Result::unwrap() on an Err value: Custom { kind: Other, error: StringError("operation not supported on wasm yet") } #115

Closed
@iceiix

Description

@iceiix

#92 added support for compiling for the wasm32-unknown-unknown target for WebAssembly, but it fails to run, panicking with "operation not supported on wasm yet" - need to adapt all code to support wasm (or compile it out with #[cfg(not(target_arch = "wasm32"))]):

[Error] panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: StringError("operation not supported on wasm yet") }', src/libcore/result.rs:1009:5

Stack:

__wbg_new_a99726b0abef495b
__wbg_new_a99726b0abef495b@http://localhost:8080/bootstrap.js:59:103
wasm-stub@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook::he1fad92af5701fc6]@[wasm code]
<?>.wasm-function[core::ops::function::Fn::call::hde3e92baaac0baf2]@[wasm code]
<?>.wasm-function[std::panicking::rust_panic_with_hook::h869ce4541d4e3554]@[wasm code]
<?>.wasm-function[std::panicking::continue_panic_fmt::h0ad726c0b188da91]@[wasm code]
<?>.wasm-function[rust_begin_unwind]@[wasm code]
<?>.wasm-function[core::panicking::panic_fmt::h4d67173bc68f6d5a]@[wasm code]
<?>.wasm-function[core::result::unwrap_failed::h69fb4e02ca2192a0]@[wasm code]
<?>.wasm-function[<core::result::Result<T, E>>::unwrap::h79a8a390611a2b6e]@[wasm code]
<?>.wasm-function[stevenarella::console::Vars::save_config::h541aec1a47a53665]@[wasm code]
<?>.wasm-function[stevenarella::main::hbc764074c370a7d5]@[wasm code]
<?>.wasm-function[main]@[wasm code]
wasm-stub@[wasm code]
main@[native code]
eval code
eval@[native code]
./index.js@http://localhost:8080/0.bootstrap.js:34:5
__webpack_require__@http://localhost:8080/bootstrap.js:90:34
__webpack_require__@[native code]
promiseReactionJob@[native code]


	__wbg_error_f7214ae7db04600c (stevenarella.js:38)
	__wbg_error_f7214ae7db04600c (bootstrap.js:65:106)
	wasm-stub
	<?>.wasm-function[console_error_panic_hook::hook::he1fad92af5701fc6]
	<?>.wasm-function[core::ops::function::Fn::call::hde3e92baaac0baf2]
	<?>.wasm-function[std::panicking::rust_panic_with_hook::h869ce4541d4e3554]
	<?>.wasm-function[std::panicking::continue_panic_fmt::h0ad726c0b188da91]
	<?>.wasm-function[rust_begin_unwind]
	<?>.wasm-function[core::panicking::panic_fmt::h4d67173bc68f6d5a]
	<?>.wasm-function[core::result::unwrap_failed::h69fb4e02ca2192a0]
	<?>.wasm-function[<core::result::Result<T, E>>::unwrap::h79a8a390611a2b6e]
	<?>.wasm-function[stevenarella::console::Vars::save_config::h541aec1a47a53665]
	<?>.wasm-function[stevenarella::main::hbc764074c370a7d5]
	<?>.wasm-function[main]
	wasm-stub
	main
	Eval Code
	eval
	./index.js (0.bootstrap.js:34)
	__webpack_require__ (bootstrap.js:90)
	__webpack_require__
	promiseReactionJob
[Error] Error importing `index.js`: – Error: Unreachable code should not be executed (evaluating 'stevenarella__WEBPACK_IMPORTED_MODULE_0__["main"]()')
Error: Unreachable code should not be executed (evaluating 'stevenarella__WEBPACK_IMPORTED_MODULE_0__["main"]()')
	(anonymous function)
	promiseReactionJob

This particular error appears to come from the Rust standard library: https://github.com/rust-lang/rust/blob/190feb65290d39d7ab6d44e994bd99188d339f16/src/libstd/sys/wasm/mod.rs#L70-L73

pub fn unsupported_err() -> crate::io::Error {
    crate::io::Error::new(crate::io::ErrorKind::Other,
                   "operation not supported on wasm yet")
}

from fs::File::create("conf.cfg") in src/console.mod.rs, relevant: https://stackoverflow.com/questions/53304832/loading-a-file-from-wasm. But once this particular issue is resolved, more incompatibilities will be uncovered, including in winit iceiix/winit#2 and glutin iceiix/glutin#1, which should wrap WebGL.

(Another option besides wasm32-unknown-unknown is wasm32-unknown-emscripten, which would fix File APIs because Emscripten has implementations for the web platform already, but Rust with Emscripten isn't as well supported: rust-windowing/winit#767 and https://rustwasm.github.io is all about wasm32-unknown-unknown, where the implementations are in pure Rust instead (albeit less complete at the moment).)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions