Skip to content

Commit 2271f9c

Browse files
grovesNLcwfitzgerald
authored andcommitted
Pass correct surface for existing canvases (#3718)
1 parent 0b53b47 commit 2271f9c

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ Bottom level categories:
4040

4141
## Unreleased
4242

43+
### Bug Fixes
44+
45+
#### WebGPU
46+
47+
* Fix crash when calling `create_surface_from_canvas`. By @grovesNL in [#3718](https://github.com/gfx-rs/wgpu/pull/3718)
48+
4349
## v0.16.0 (2023-04-19)
4450

4551
### Major changes

wgpu/src/backend/web.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ impl<T> From<Identified<T>> for ObjectId {
6363
}
6464
}
6565

66-
#[allow(unused_variables)]
67-
impl<T> From<(Identified<T>, Sendable<T>)> for ObjectId {
68-
fn from((id, _data): (Identified<T>, Sendable<T>)) -> Self {
69-
Self::new(
70-
// TODO: the ID isn't used, so we hardcode it to 1 for now until we rework this
71-
// API.
72-
core::num::NonZeroU64::new(1).unwrap(),
73-
#[cfg(feature = "expose-ids")]
74-
id.0,
75-
)
76-
}
77-
}
78-
7966
#[derive(Clone, Debug)]
8067
pub(crate) struct Sendable<T>(T);
8168
unsafe impl<T> Send for Sendable<T> {}

wgpu/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ pub struct ObjectId {
10041004
}
10051005

10061006
impl ObjectId {
1007-
const UNUSED: Self = ObjectId {
1007+
pub(crate) const UNUSED: Self = ObjectId {
10081008
id: None,
10091009
#[cfg(feature = "expose-ids")]
10101010
global_id: None,

wgpu/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,9 +1616,9 @@ impl Instance {
16161616
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
16171617
data: Box::new(surface),
16181618
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
1619-
id: ObjectId::from(surface),
1619+
id: ObjectId::UNUSED,
16201620
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
1621-
data: Box::new(()),
1621+
data: Box::new(surface.1),
16221622
config: Mutex::new(None),
16231623
})
16241624
}
@@ -1652,9 +1652,9 @@ impl Instance {
16521652
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
16531653
data: Box::new(surface),
16541654
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
1655-
id: ObjectId::from(surface),
1655+
id: ObjectId::UNUSED,
16561656
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
1657-
data: Box::new(()),
1657+
data: Box::new(surface.1),
16581658
config: Mutex::new(None),
16591659
})
16601660
}

0 commit comments

Comments
 (0)