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

[trick] to unlock toriiClient with safari/firefox #2038

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

notV4l
Copy link
Collaborator

@notV4l notV4l commented Jun 10, 2024

Description

With local dojo & dojo.js

in dojo.js / torii-wasm / Cargo.toml
refer local dependencies for dojo crates

dojo-types = { path = "../../../../dojo/crates/dojo-types" }
torii-client = { path = "../../../../dojo/crates/torii/client" }
torii-grpc = { path = "../../../../dojo/crates/torii/grpc" }
torii-relay = { path = "../../../../dojo/crates/torii/libp2p" }

in dojo.js / torii-wasm / rust-toolchain.toml
update version to

[toolchain]
channel = "1.76.0"

build dojo.js packages 'pnpm build'
build torii
tested with dojo-starter & dojo.js/examples/react/react-app

Related issue

dojoengine/dojo.js#130

@glihm
Copy link
Collaborator

glihm commented Jun 10, 2024

@Larkooo @ponderingdemocritus if you have a chance to confirm this change, it could be awesome. 🙏

@Larkooo
Copy link
Collaborator

Larkooo commented Jun 10, 2024

@Larkooo @ponderingdemocritus if you have a chance to confirm this change, it could be awesome. 🙏

This will only unlock the start_subscription blocking function on Safari/Firefox as it always returns empty state updates even where there aren't any. Because it seems like the main issue with Safari/Firefox right now is that they are blocking on our GRPC subscription streams until we receive a new message.

I'm not sure if this should be the definite solution to implement but I think we can get a better grasp of whats happening thanks to it.
Also, this only solves the blocking "start_subscription" function called when the torii client is instantiated. Not other subscriptions like entity and event messages updates as Safari/Firefox are still gonna block on those

@notV4l
Copy link
Collaborator Author

notV4l commented Jun 10, 2024

Not other subscriptions like entity and event messages updates as Safari/Firefox are still gonna block on those

thx, i applied same trick for other subscribers

@glihm
Copy link
Collaborator

glihm commented Jun 10, 2024

Thanks for the update @notV4l on the other subscribers.

As @Larkooo mentioned, it could be great to solve the underlying problem. Let's keep this PR open until @Larkooo gives some feedback on lower layers. And if gRPC issue with WASM futures is too deep, this PR will be the solution to go. 👍

@glihm glihm added the torii label Jun 10, 2024
@ponderingdemocritus
Copy link
Contributor

I don't see any downside to shipping this @glihm @Larkooo . Ofc it's not the final solution, but it's a huge unlock in anycase, and is essential to most games in production state that use grpc

Nice work @notV4l

@Larkooo
Copy link
Collaborator

Larkooo commented Jun 10, 2024

I don't see any downside to shipping this @glihm @Larkooo . Ofc it's not the final solution, but it's a huge unlock in anycase, and is essential to most games in production state that use grpc

Nice work @notV4l

I am not against merging it but it will break the current torii clients, so appropriate changes need to be made to dojo.js/torii-wasm on your side and dojo.c on my side. As we will need to handle empty stream messages without panicking.
As of right now, we expect all subscription messages to contain entity updates / event messages.

There will be also be some work to be done on the ModelDiff subscription part of the torii-client, which will need to handle empty state updates. Perhaps also changing the protobuf types to properly return None "state_update", instead of a zero filled state update.
@notV4l if you can take a look pls https://github.com/dojoengine/dojo/blob/main/crates/torii/client/src/client/subscription.rs

@Larkooo Larkooo force-pushed the torii_firefox_safari branch from 6f4cf53 to 4b1f8c1 Compare June 13, 2024 13:32
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.

Project coverage is 68.36%. Comparing base (1fe0488) to head (a5b0c31).

Files Patch % Lines
crates/torii/grpc/src/client.rs 0.00% 22 Missing ⚠️
...ates/torii/grpc/src/server/subscriptions/entity.rs 0.00% 4 Missing ⚠️
...rii/grpc/src/server/subscriptions/event_message.rs 0.00% 4 Missing ⚠️
.../torii/grpc/src/server/subscriptions/model_diff.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2038      +/-   ##
==========================================
- Coverage   68.41%   68.36%   -0.05%     
==========================================
  Files         323      323              
  Lines       40258    40286      +28     
==========================================
+ Hits        27541    27543       +2     
- Misses      12717    12743      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Larkooo Larkooo marked this pull request as ready for review June 13, 2024 13:56
Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work guys, let's iterate with those changes as a new base to at least unlock all major browsers.

@Larkooo Larkooo merged commit a5f043e into dojoengine:main Jun 13, 2024
11 of 13 checks passed
Larkooo added a commit to Larkooo/dojo that referenced this pull request Jun 13, 2024
* trick: to unlock toriiClient with safari/firefox

* same trick for other subscribers

* refactor: send initial stream message directly

* chore: avoid sender clone

---------

Co-authored-by: Nasr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants