Skip to content

Permit close websockets#4

Open
buxx wants to merge 1 commit intonot-fl3:masterfrom
buxx:permit-close-ws
Open

Permit close websockets#4
buxx wants to merge 1 commit intonot-fl3:masterfrom
buxx:permit-close-ws

Conversation

@buxx
Copy link
Copy Markdown

@buxx buxx commented Aug 18, 2022

Hello,

I'm confronting a bug when I recreate web sockets. There is the situation in my program :

  1. Websocket::connect is called one time to establish the connection.
  2. In a second time, websocket is destroyed (game display another screen where web socket is unnecessary)
  3. In a third time, the step 1 code is called again, so Websocket::connect called again.

It results an error when messages received by first websocket: first created websocket has never been closed. So in my game, I use the following close function to prevent this.

But I have a similar issue with webassembly target. Error in exact previous situation. Brower errors are :

Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable not-fl3.github.io__miniquad-samples__mq_js_bundle.js:1

PanicInfo { payload: Any { .. }, message: Some(already borrowed: BorrowMutError), location: Location { file: "/home/bastiensevajol/.cargo/registry/src/github.com-1ecc6299db9ec823/miniquad-0.3.10/src/native/wasm.rs", line: 95, col: 35 }, can_unwind: true } not-fl3.github.io__miniquad-samples__mq_js_bundle.js:1:10657

Uncaught RuntimeError: unreachable executed
    onmousemove http://127.0.0.1:5000/static/not-fl3.github.io__miniquad-samples__mq_js_bundle.js:1
engine.wasm:1948550:1

PanicInfo { payload: Any { .. }, message: Some(already borrowed: BorrowMutError), location: Location { file: "/home/bastiensevajol/.cargo/registry/src/github.com-1ecc6299db9ec823/miniquad-0.3.10/src/native/wasm.rs", line: 95, col: 35 }, can_unwind: true } not-fl3.github.io__miniquad-samples__mq_js_bundle.js:1:10657

The src/native/wasm.rs concerned code is :

fn with<T, F: FnOnce(&mut WasmGlobals) -> T>(f: F) -> T {
    GLOBALS.with(|globals| {
        let mut globals = globals.borrow_mut();
        let globals = globals.as_mut().unwrap();
        f(globals)
    })
}

Can you help me about solving this bug with webassembly too ? I am noob with WASM/JS things :(

@buxx buxx force-pushed the permit-close-ws branch from a246425 to 476d8eb Compare August 18, 2022 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant