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

Fix various codebase rots (stale CI, new Rust lints, broken MSRV checks by transitive dependency upgrades) #164

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Jul 29, 2024

Rust 1.80 from July 25th 2024 points out that armv7 is not a known, valid value for the target_arch cfg variable. This is confirmed by the docs not listing it either: https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch.

Hence drop this entirely, and rely purely on target_arch = "arm".

Furthermore it also points out that we don't have a test and api-level-30 feature: remove the unused test feature and reexpose ConfigurationRef::screen_round() which was behind a previously unsettable feature = "api-level-30".


EDIT: PR updated to fix everything that was holding back our CI.

[Rust 1.80 from July 25th 2024] points out that `armv7` is not a known,
valid value for the `target_arch` cfg variable.  This is confirmed by
the docs not listing it either:
https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch

Hence drop this entirely, and rely purely on `target_arch = "arm"`.

[Rust 1.80 from July 25th 2024]: https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html
…test`

Some code copied from the NDK carried over the respective `feature`
`cfg` guards, without ever adding the feature to the `[features]` list
in `Cargo.toml`.  Now that Rust detects these mishaps, we can fix it
by removing `test` (bindings don't seem to be run-tested) and reexpose
`ConfigurationRef::screen_round()` which was behind a previously
unsettable `feature = "api-level-30"`.

Also remove `unsafe impl Send/Sync for ConfigurationRef` since the
upstream `ndk` already declares `Configuration` to be `Send` and `Sync`,
and `RwLock` and `Arc` carry that through.
Copy link
Collaborator

@rib rib left a comment

Choose a reason for hiding this comment

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

Thanks, this all looks good to me!

@MarijnS95
Copy link
Member Author

@rib how do we want to deal with this for our MSRV:

error: package `num_enum v0.7.3` cannot be built because it requires rustc 1.70.0 or newer, while the currently active rustc version is 1.69.0
Either upgrade to rustc 1.70.0 or newer, or use
cargo update -p [email protected] --precise ver
where `ver` is the latest version of `num_enum` supporting rustc 1.69.0

Shall we run a cargo +nightly generate-lockfile -Zminimal-versions before running the MSRV check?

@MarijnS95 MarijnS95 requested a review from rib November 11, 2024 11:32
@MarijnS95 MarijnS95 changed the title Fix unexpected-cfgs lint detected since Rust 1.80 Fix various codebase rots (stale CI, new Rust lints, broken MSRV checks by transitive dependency upgrades) Nov 11, 2024
@MarijnS95
Copy link
Member Author

@notgull would love to have your review on this as well, now that the CI is made green again.

@notgull
Copy link
Contributor

notgull commented Nov 11, 2024

Please rerun the CI, I don't think this fixes the "invalid configuration" errors I was getting.

@MarijnS95
Copy link
Member Author

MarijnS95 commented Nov 11, 2024

@notgull the CI has ran quite a few times on a personal branch before I force-pushed the final changes here, I didn't see any spurious "invalid configuration" errors on any run and don't see how those would randomly trigger on a re-run.

Otherwise, please link your CI failure. There is only one run from your PR: https://github.com/rust-mobile/android-activity/actions/workflows/ci.yml?query=actor%3Anotgull

And that run failed specifically because of the issues that are fixed in this PR: https://github.com/rust-mobile/android-activity/actions/runs/11771937579

Copy link
Contributor

@notgull notgull left a comment

Choose a reason for hiding this comment

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

I don't see anything objectionable.

…ndSync` and unwritten `redraw_needed` field
The `actions-rs` containers haven't been maintained and updated for
years and don't need to: GitHub's actions environment already comes
fully loaded with a complete `stable` Rust installation with the
standard tools (in this case `rustfmt`).  Remove the remaining toolchain
setup (which was already replaced with `hecrj/setup-rust-action`
elsewhere) to get rid of ancient Node 12 deprecation warnings.
…heck

Use `-Zminimal-versions` in our MSRV check.  This not only ensures
our minimum version bounds are actually solid and tested (even if
they may be a bit conservative at times, i.e. we could allow older
versions except for the crates that are bumped in this patch which were
explicitly build-tested), it also allows us to use this as a base for
the MSRV test, and preempt us from failing it whenever a (transitive!)
dependency bumps its MSRV beyond ours in a *semver-compatible* release.
Comment on lines +13 to +16
/// The value held by this reference **will change** with every [`super::MainEvent::ConfigChanged`]
/// event that is raised. You should **not** [`Clone`] this type to compare it against a
/// "new" [`super::AndroidApp::config()`] when that event is raised, since both point to the same
/// internal [`ndk::configuration::Configuration`] and will be identical.
Copy link
Member Author

Choose a reason for hiding this comment

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

@rib I don't have any alternative to propose to users to compare configurations besides calling the expensive fn copy() to make a deep-clone of ndk::configuration::Configuration which exactly defeats the purpose of initially making this "cheap to copy".

By having this an updatable RwLock rather than a simple Arc it is no longer possible to compare for configuration differences and prevent possibly expensive reconfiguration/updates in the users' loops. If this was "just an Arc" users could do exactly that while still "cloning" the configuration around cheaply.

In any case, every time the callback fires a new AConfiguration is allocated and filled anyway, rather than "reading into" the existing AConfiguration. But the docs at https://developer.android.com/ndk/reference/group/configuration#aconfiguration_fromassetmanager are incredibly vague by mentioning Create and return a new AConfiguration while it has to take an existing allocated (but possibly new/empty?) AConfiguration.

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

Successfully merging this pull request may close these issues.

3 participants