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

Update raw-window-handle to v0.6 #1670

Merged

Conversation

declantsien
Copy link
Contributor

@declantsien declantsien commented Mar 13, 2024

  • Tested on all platforms changed
    Only tested on devices using Linux
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
    None
  • Created or updated an example program if it would help users understand this functionality

@declantsien declantsien force-pushed the update-raw-window-handle branch 4 times, most recently from 5e513c2 to 92a5ab0 Compare March 13, 2024 04:30
@kchibisov
Copy link
Member

We already have #1582 for that, though we have an option for 0.6 just for the time being unless I have time to look into the safe handle stuff and how it could be approached in glutin.

glutin/src/api/egl/config.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/glx/display.rs Outdated Show resolved Hide resolved
glutin/src/api/wgl/display.rs Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
glutin-winit/src/window.rs Outdated Show resolved Hide resolved
@kchibisov
Copy link
Member

I'd just post a review, since there's nothing wrong with just using raw version of 0.6, since it's just small update.

@MarijnS95
Copy link
Member

A lot of changes here may snoop the implementation from ash-rs/ash#799 which - to my knowledge - treats (non)-nullable parameters accordingly.

@declantsien declantsien force-pushed the update-raw-window-handle branch 2 times, most recently from ca6d970 to 6c16bb3 Compare March 19, 2024 08:44
CHANGELOG.md Outdated Show resolved Hide resolved
glutin-winit/src/lib.rs Outdated Show resolved Hide resolved
glutin-winit/src/lib.rs Outdated Show resolved Hide resolved
glutin-winit/src/window.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/surface.rs Outdated Show resolved Hide resolved
glutin_examples/src/lib.rs Outdated Show resolved Hide resolved
glutin_examples/src/lib.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/config.rs Outdated Show resolved Hide resolved
@declantsien declantsien force-pushed the update-raw-window-handle branch 2 times, most recently from 0fefa0b to b209d27 Compare March 19, 2024 12:09
@sarthakvk
Copy link

sarthakvk commented Apr 14, 2024

Is there a plan to merge this PR? @declantsien

@kchibisov
Copy link
Member

In general, re-request the review with github UI when it's ready or explicitly indicate the state if you're not interested anymore.

Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

Overall seeing a bit too many semantical changes that I'm not immediately content with. raw-window-handle 0.6 gives us the ability to know that values are intentionally 0/null() by setting an Option to None, but we're not taking this opportunity to validate whether the underlying API can and should handle that value, or that we should bail. In some cases there are unwraps, or None propagation, or ? propagation making things harder to follow and validate.

glutin-winit/src/lib.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
glutin/src/api/egl/display.rs Outdated Show resolved Hide resolved
let (wgl_extra, client_extensions) =
super::load_extra_functions(window.hinstance as _, window.hwnd as _)?;
let (wgl_extra, client_extensions) = super::load_extra_functions(
window.hinstance.map(|i| i.get()).unwrap_or(0) as _,
Copy link
Member

Choose a reason for hiding this comment

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

unwrap_or_else?

I'm unfamiliar with this code to say if it's okay to pass 0 for HINSTANCE. There are multiple getters but don't know if any should be used.

Copy link
Member

Choose a reason for hiding this comment

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

it's the same as before, because it could be 0, which is default for rwh 0.5 and lower.

Copy link
Member

@MarijnS95 MarijnS95 May 6, 2024

Choose a reason for hiding this comment

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

@kchibisov yes that is the point: it could have been passed before, but now that we know the raw-window-handle API allows zero, we should take a second to realize whether that is actually valid inside super::load_extra_functions().

Copy link
Member

Choose a reason for hiding this comment

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

Our own safety docs already say that this must be "valid":

/// # Safety
///
/// The `native_window` must point to the valid platform window and have
/// valid `hinstance`.
pub unsafe fn new(

So I think this should be a panic!()/.unwrap()/ok_or...()?.

Copy link
Member

@MarijnS95 MarijnS95 May 6, 2024

Choose a reason for hiding this comment

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

Looking further than that, load_extra_functions() calls GetClassInfoExW() and CreateWindowExW(), both of which allow NULL, so the safety docs are likely too strict and should be removed if we keep this unwrap_or(0).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I think this should be a panic!()/.unwrap()/ok_or...()?.

I go with .unwrap().

Copy link
Member

Choose a reason for hiding this comment

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

Yes that is a good idea. If people were previously implicitly passing 0 (mismatching the # Safety docs), we'll catch that and can always amend the code with a new patch release.

glutin_examples/examples/switch_render_thread.rs Outdated Show resolved Hide resolved
glutin_examples/src/lib.rs Outdated Show resolved Hide resolved
@declantsien
Copy link
Contributor Author

@kchibisov Can you help with the CI error. Wired cfg errors.

@declantsien
Copy link
Contributor Author

@kchibisov Can you help with the CI error. Wired cfg errors.

The error is from the rust nightly. Tried with an old build nightly-2024-04-05 the errors are gone. Since we don't have a rust-toolchain.toml file, no idea how to deal with it.
Another question, why don't we use Cargo.lock? Cargo.lock is useful for reproducible build.

@kchibisov
Copy link
Member

Another question, why don't we use Cargo.lock? Cargo.lock is useful for reproducible build.

The old default behavior for rust was to not include Cargo.lock for libraries. They changed that to include last year iirc.

Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

Should be good after rebase.

@declantsien
Copy link
Contributor Author

Should be good after rebase.

Nice

@declantsien
Copy link
Contributor Author

Another question, why don't we use Cargo.lock? Cargo.lock is useful for reproducible build.

The old default behavior for rust was to not include Cargo.lock for libraries. They changed that to include last year iirc.

Right. Good to know. Thanks.

@MarijnS95
Copy link
Member

Another question, why don't we use Cargo.lock? Cargo.lock is useful for reproducible build.

A reproducible build (for libraries) is "useless" when a published crate is on crates.io. Only semver version (range) dependencies from Cargo.toml are taken into account when your crate is used in another project. cargo doesn't magically "merge" its Cargo.lock with the lockfile of the current project:

https://doc.rust-lang.org/cargo/faq.html#:~:text=However%2C%20this%20determinism%20can%20give%20a%20false%20sense%20of%20security%20because%20Cargo.lock%20does%20not%20affect%20the%20consumers%20of%20your%20package%2C%20only%20Cargo.toml%20does%20that.

CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
# Unreleased

- Bump MSRV from `1.65` to `1.70`.
- **Breaking:** updated `raw-window-handle` dependency to `0.6.1`.
Copy link
Member

Choose a reason for hiding this comment

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

Question for @kchibisov: the changelog seems to have a mix of past- and present-tense. What should we pick?

glutin-winit/Cargo.toml Outdated Show resolved Hide resolved
MarijnS95
MarijnS95 previously approved these changes May 6, 2024
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

One more cleanup request for an unreachable if display.is_null(), but seems like we're getting somewhere otherwise.

glutin/src/api/egl/display.rs Show resolved Hide resolved
@declantsien declantsien force-pushed the update-raw-window-handle branch 2 times, most recently from ade655b to d941c1c Compare May 6, 2024 08:08
@MarijnS95 MarijnS95 dismissed their stale review May 6, 2024 08:15

Not happy with how valid open comments get marked as resolved.

@declantsien declantsien force-pushed the update-raw-window-handle branch 2 times, most recently from 725b03e to 3fbda28 Compare May 6, 2024 08:22
@MarijnS95
Copy link
Member

One item remaining, the rest looks good:

@declantsien declantsien force-pushed the update-raw-window-handle branch 3 times, most recently from 5f90db4 to e20c41d Compare May 6, 2024 08:55
@declantsien
Copy link
Contributor Author

declantsien commented May 6, 2024

One item remaining, the rest looks good:

@MarijnS95 I think I am done with your requests.

@kchibisov kchibisov merged commit 8fa8593 into rust-windowing:master May 21, 2024
43 checks passed
@@ -22,11 +22,11 @@ wayland = ["glutin-winit/wayland", "winit/wayland-dlopen", "winit/wayland-csd-ad
glutin = { path = "../glutin", default-features = false }
glutin-winit = { path = "../glutin-winit", default-features = false }
png = { version = "0.17.6", optional = true }
raw-window-handle = "0.5"
raw-window-handle = "0.6"
winit = { version = "0.29.2", default-features = false, features = ["rwh_05"] }
Copy link
Contributor

@marc2332 marc2332 May 25, 2024

Choose a reason for hiding this comment

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

Any reason this winit was left unchanged with rwh_05 instead of rwh_06 ?

I just noticed it when resolving conflicts in #1675

Copy link
Member

Choose a reason for hiding this comment

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

it's example, doesn't really matter. Could use 06.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, seems to work just fine, I simply found it odd 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants