-
Notifications
You must be signed in to change notification settings - Fork 269
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
Start addressing some wasm32-unknown-unknown errors for matrix-sdk-ui crate #4122
Conversation
55f7b61
to
617c622
Compare
#[cfg(target_arch = "wasm32")] | ||
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; | ||
#[cfg(not(target_arch = "wasm32"))] | ||
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[cfg(target_arch = "wasm32")] | |
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; | |
#[cfg(not(target_arch = "wasm32"))] | |
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; | |
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + SendOutsideWasm + 'a>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this definition already existed though, why did you move it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to expose the .boxed
method on the wasm version of the code (it was present on the real future, but not the Wasm version). It seemed like this was where the wasm future was being defined, so I wanted to move the BoxFuture method here so it can be exposed in the same place.
#[cfg(not(target_arch = "wasm32"))] | ||
impl<'a, F, T> BoxFutureExt<'a, T> for F | ||
where | ||
F: Future<Output = T> + 'a + Send, | ||
T: 'a, | ||
{ | ||
fn box_future(self) -> BoxFuture<'a, T> { | ||
self.boxed() | ||
} | ||
} | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
impl<'a, F, T> BoxFutureExt<'a, T> for F | ||
where | ||
F: Future<Output = T> + 'a, | ||
T: 'a, | ||
{ | ||
fn box_future(self) -> BoxFuture<'a, T> { | ||
self.boxed_local() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl blocks can be merged the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was struggling to get it to compile with the extra + Send
trait needed on the not-wasm32 version.
617c622
to
b93d3b7
Compare
26943b1
to
ac6b065
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4122 +/- ##
==========================================
- Coverage 84.89% 84.84% -0.05%
==========================================
Files 272 271 -1
Lines 29167 29179 +12
==========================================
- Hits 24761 24758 -3
- Misses 4406 4421 +15 ☔ View full report in Codecov by Sentry. |
With an additional change to relax the use of Send+Sync in the eyeball package, I have the rest of this crate building locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible, left a couple of nits.
@@ -512,7 +509,7 @@ macro_rules! impl_event_handler { | |||
impl<Ev, Fun, Fut, $($ty),*> EventHandler<Ev, ($($ty,)*)> for Fun | |||
where | |||
Ev: SyncEvent, | |||
Fun: FnOnce(Ev, $($ty),*) -> Fut + Clone + SendOutsideWasm + SyncOutsideWasm + 'static, | |||
Fun: FnOnce(Ev, $($ty),*) -> Fut + Clone + Send + Sync + 'static, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why would you need Send
+ Sync
unconditionally here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning on continuing this PR or should we close it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restored the Send/Sync here -- until the eyeball change lands we can't complete a wasm build of this yet anyway, so there will need to be a second PR to handle stragglers at that point.
This commit adjusts types and traits to support targeting wasm32.
b918f09
to
2592405
Compare
Afraid I'm going to have to close this for now, will revisit in the new year when we have time to focus on this effort again. |
I rebased my patches and bunch of new changes: https://github.com/matrix-org/matrix-rust-sdk/compare/main...maan2003:matrix-rust-sdk:push-rumyppqlqkkq?expand=0 But I don't have the energy to go through review :/ |
This change consists mostly of type-wrangling to support building the matrix-sdk-ui crate for wasm32-unknown-unknown. It is a step along the way of (ideally) supporting wasm32 throughout the entire project. The matrix-sdk-ui packages is not yet compiling due to some blocking issues, but these changes should be able to be landed now as a step towards that goal.
The changes consist of one of two main types.
Signed-off-by: Daniel Salinas