Skip to content
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

netplay: patch export globals and sync them #715

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

JerwuQu
Copy link
Contributor

@JerwuQu JerwuQu commented Apr 28, 2024

Solves #649 and #542.

Tested with the cart from #542 (comment).

I understand if this is not the direction you wanna go and maybe something should be done differently, but it's a start at finally getting this fixed :)

@aduros
Copy link
Owner

aduros commented Jun 2, 2024

I like the idea of preprocessing the wasm to export globals, but using JSON in the serialization seems inefficient.

I wonder if we can assume that the entire globals section is a known fixed size and ordering. Then we'd only need to write the values into the saved state. I think we could also write each value as binary, the exact type also being known. What do you think?

@JerwuQu
Copy link
Contributor Author

JerwuQu commented Jun 3, 2024

Unfortunately I don't think we can get globals as binary data from JS and would have to convert it back and forth from JS types ourselves. At that point I'd guess the browser implementation of JSON isn't actually slower and is a lot less code.

I'd agree with looking into fancier solutions if we serialized this often, but to my knowledge it's only on client connections and user savestates (?)

Feel free to look into it! I'm pretty happy with the WASM patcher code but for the State-code I just made something that works :)

@aduros
Copy link
Owner

aduros commented Jul 22, 2024

I'd agree with looking into fancier solutions if we serialized this often, but to my knowledge it's only on client connections and user savestates (?)

For netplay we serialize the state every frame, and rollbacks can result in multiple unserialize/serializes in a single frame. Not a huge deal, but it would be good to optimize later 🙂 Let's merge it for now to unblock wasm languages that rely on globals.

@aduros aduros merged commit 49e6303 into aduros:main Jul 22, 2024
5 checks passed
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.

2 participants