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

Separate Yew Platform #2893

Merged
merged 10 commits into from
Oct 20, 2022
Merged

Separate Yew Platform #2893

merged 10 commits into from
Oct 20, 2022

Conversation

futursolo
Copy link
Member

@futursolo futursolo commented Sep 28, 2022

Description

Fixes #2839.

  • A new crate prokio (exported as yew::platform) has been published separately.
  • A new crate pinned (previously yew::platform::pinned) has been published separately.
  • Feature tokio has been removed.

Checklist

  • I have reviewed my own code
  • I have added tests

@futursolo futursolo added the A-yew-platform Area: The yew-platform crate label Sep 28, 2022
github-actions[bot]
github-actions bot previously approved these changes Sep 28, 2022
@github-actions
Copy link

github-actions bot commented Sep 28, 2022

Visit the preview URL for this PR (updated for commit 680590b):

https://yew-rs-api--pr2893-platform-crate-ulfy6xeo.web.app

(expires Wed, 26 Oct 2022 11:47:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

github-actions[bot]
github-actions bot previously approved these changes Sep 28, 2022
@github-actions
Copy link

github-actions bot commented Sep 28, 2022

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 307.504 308.435 307.995 0.332
Hello World 10 597.808 599.085 598.349 0.512
Function Router 10 2189.255 2214.459 2200.155 7.050
Concurrent Task 10 1008.410 1010.347 1009.555 0.575

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 353.292 355.083 354.231 0.540
Hello World 10 604.436 608.029 605.649 1.113
Function Router 10 2204.780 2225.530 2212.927 6.477
Concurrent Task 10 1008.177 1010.211 1009.135 0.747

github-actions[bot]
github-actions bot previously approved these changes Sep 28, 2022
@github-actions
Copy link

github-actions bot commented Sep 28, 2022

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 106.134 106.140 +0.006 +0.006%
boids 170.280 170.285 +0.005 +0.003%
communication_child_to_parent 90.027 90.029 +0.002 +0.002%
communication_grandchild_with_grandparent 104.884 104.887 +0.003 +0.003%
communication_grandparent_to_grandchild 100.747 100.743 -0.004 -0.004%
communication_parent_to_child 87.131 87.135 +0.004 +0.004%
contexts 107.352 107.359 +0.008 +0.007%
counter 85.049 85.049 0 0.000%
counter_functional 85.523 85.521 -0.002 -0.002%
dyn_create_destroy_apps 87.881 87.882 +0.001 +0.001%
file_upload 99.621 99.620 -0.001 -0.001%
function_memory_game 162.740 162.750 +0.010 +0.006%
function_router 346.997 347.029 +0.032 +0.009%
function_todomvc 157.564 157.566 +0.002 +0.001%
futures 221.914 221.914 0 0.000%
game_of_life 104.542 104.542 0 0.000%
immutable 180.977 180.974 -0.003 -0.002%
inner_html 81.911 81.912 +0.001 +0.001%
js_callback 110.885 110.880 -0.005 -0.004%
keyed_list 195.403 195.406 +0.003 +0.001%
mount_point 84.657 84.658 +0.001 +0.001%
nested_list 111.617 111.624 +0.007 +0.006%
node_refs 92.531 92.530 -0.001 -0.001%
password_strength 1546.204 1546.203 -0.001 -0.000%
portals 95.944 95.949 +0.005 +0.005%
router 316.802 316.826 +0.024 +0.008%
simple_ssr 151.657 151.661 +0.004 +0.003%
ssr_router 392.151 392.185 +0.033 +0.008%
suspense 108.619 108.622 +0.003 +0.003%
timer 87.912 87.914 +0.002 +0.002%
todomvc 138.877 138.878 +0.001 +0.001%
two_apps 85.712 85.714 +0.002 +0.002%
web_worker_fib 151.865 151.873 +0.008 +0.005%
webgl 84.376 84.352 -0.024 -0.029%

✅ None of the examples has changed their size significantly.

github-actions[bot]
github-actions bot previously approved these changes Sep 28, 2022
@@ -0,0 +1,40 @@
[package]
name = "yew-platform"
Copy link
Member

Choose a reason for hiding this comment

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

What if we dropped the yew- prefix from here? It can be generic crate that can be used to pick an async runtime between tokio and wasm-bindgen-futures (JS promises)

Name idea: promise + tokio = prokio

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. I have published the crate under name prokio.

github-actions[bot]
github-actions bot previously approved these changes Oct 19, 2022
# Conflicts:
#	packages/yew/Cargo.toml
github-actions[bot]
github-actions bot previously approved these changes Oct 19, 2022
@@ -26,7 +26,6 @@
//! - `csr`: Enables Client-side Rendering support and [`Renderer`]. Only enable this feature if you
//! are making a Yew application (not a library).
//! - `ssr`: Enables Server-side Rendering support and [`ServerRenderer`].
//! - `tokio`: Enables future-based APIs on non-wasm32 targets with tokio runtime.
Copy link
Member Author

Choose a reason for hiding this comment

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

Both tokio on wasi with threading support and async-std's spawn_local are unstable.
tokio and wasm-bindgen-futures are going to be the only runtime that is supported by prokio for the moment.

Hence, I feel it might be better to forego the tokio feature until we need it.

Copy link
Member

Choose a reason for hiding this comment

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

I like this this way. Tokio is hidden behind the pseudo-runtime (prokio) and doesn't need to be exposed here.

@futursolo futursolo requested a review from ranile October 19, 2022 11:58
Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I'm in favor of the removed tokio feature. I would prefer if the new crates were placed under the yewstack organization though, just like how implicit-clone is

Comment on lines -21 to -32
cargo clippy --release --no-default-features --features tokio -- --deny=warnings
cargo clippy --release --no-default-features --features csr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features default,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features csr,default,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features hydration,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features default,hydration,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features ssr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features csr,ssr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features default,ssr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features csr,default,ssr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features hydration,ssr,tokio -- --deny=warnings
cargo clippy --release --no-default-features --features default,hydration,ssr,tokio -- --deny=warnings
Copy link
Member

Choose a reason for hiding this comment

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

I assume they move to prokio, correct?

Copy link
Member Author

@futursolo futursolo Oct 20, 2022

Choose a reason for hiding this comment

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

It is removed completely and does not present in prokio as well. As previously mentioned, the tokio feature is not very useful. I expect the current situation to stay years before it changes. So I guess it might be better to remove tokio feature and read it when we need it.

Comment on lines +47 to +48
#[doc(inline)]
pub use prokio::*;
Copy link
Member

Choose a reason for hiding this comment

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

I think you can put this in lib.rs to have the same effect:

#[doc(inline)]
pub use prokio as platform;

That way you can avoid duplicating the doc comments.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is intentional. The documentation of yew::platform and prokio is slightly different. The wording is adjusted to mention Yew in the documentation.

@@ -26,7 +26,6 @@
//! - `csr`: Enables Client-side Rendering support and [`Renderer`]. Only enable this feature if you
//! are making a Yew application (not a library).
//! - `ssr`: Enables Server-side Rendering support and [`ServerRenderer`].
//! - `tokio`: Enables future-based APIs on non-wasm32 targets with tokio runtime.
Copy link
Member

Choose a reason for hiding this comment

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

I like this this way. Tokio is hidden behind the pseudo-runtime (prokio) and doesn't need to be exposed here.

Comment on lines +38 to +39
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
Copy link
Member

Choose a reason for hiding this comment

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

Why do we still need a direct dependency on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is due to yew is using wasm_bindgen_futures::JsFuture in a couple places.

@futursolo futursolo merged commit da09755 into yewstack:master Oct 20, 2022
@futursolo
Copy link
Member Author

I would prefer if the new crates were placed under the yewstack organization though, just like how implicit-clone is

I have moved prokio to https://github.com/yewstack/prokio.

@futursolo futursolo deleted the platform-crate branch December 15, 2022 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-platform Area: The yew-platform crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make yew::platform it's own indepenedent crate
2 participants