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

egui-winit: Remove android-activity dependency + add Activity backend features #2863

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

rib
Copy link
Contributor

@rib rib commented Apr 1, 2023

Instead of depending on android-activity directly, this exposes the android-native-activity and android-game-activity features from Winit (via egui-winit and eframe).

The overall issue here is that Android applications will very likely need to implement a subclass of Activity in Java or Kotlin and when using android-activity that means they will have to choose to subclass NativeActivity or GameActivity. Since there are significant pros and cons to each one it isn't really appropriate for Egui to force a choice here.

Conceptually the android-activity crate is the lowest-level, runtime crate for a native Android application written in Rust and then middleware like Winit and Egui sit on top of this. With the way Cargo features work then if we want make the low-level crate configurable for applications then we don't really have any choice but to expose equivalent features via middleware frameworks (such as Egui) that applications depend on.

This ensures that applications can choose what android-activity backend they use while also relying on Winit to decide what version of android-activity to use - without increasing the risk of a version conflict by having a direct dependency.

(NB: Egui doesn't currently use the android-activity API itself)

Since android-activity provides the android_main() entry point for Android applications it's not possible to link in multiple versions of the android-activity crate and so it's particularly important to avoid unnecessary direct dependencies that could cause a version conflict in the future.

To help avoid the need for applications to directly depend on android-activity the Winit crate re-exports the android-activity API and exposes features to configure the backend so that application crates can instead rely on Winit to pull in a compatible version of android-activity. (This way version bumps for android-activity only need to be synchronized with the Winit crate).

CI now enables the android-native-activity feature for testing.

Fixes: #2829
Fixes: #2720
Closes: #2834

Cc: @ardocrat

Instead of depending on android-activity directly, this exposes the
android-native-activity and android-game-activity features from Winit.

This ensures that applications can choose what android-backend they use
while also relying on Winit to decide what version of android-activity to
use - without increasing the risk of a version conflict by having a direct
dependency.

_(NB: Egui doesn't currently use the android-activity API itself)_

Since android-activity provides the `android_main()` entry point for
Android applications it's not possible to link in multiple version of
the android-activity crate and so it's particularly important to
avoid unnecessary direct dependencies that could cause a version
conflict in the future.

To help avoid the need for applications to directly depend on
android-activity the Winit crate re-exports the android-activity API
and exposes features to configure the backend so that application crates
can instead rely on Winit to pull in a compatible version of
android-activity. (This way version bumps for android-activity only
need to be synchronized with the Winit crate).

CI now enables the `android-native-activity` feature for testing.

Fixes: emilk#2829
Fixes: emilk#2720
Closes: emilk#2834
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Thank you!

@emilk emilk merged commit 89e4288 into emilk:master Apr 18, 2023
TicClick pushed a commit to TicClick/egui that referenced this pull request Apr 18, 2023
Instead of depending on android-activity directly, this exposes the
android-native-activity and android-game-activity features from Winit.

This ensures that applications can choose what android-backend they use
while also relying on Winit to decide what version of android-activity to
use - without increasing the risk of a version conflict by having a direct
dependency.

_(NB: Egui doesn't currently use the android-activity API itself)_

Since android-activity provides the `android_main()` entry point for
Android applications it's not possible to link in multiple version of
the android-activity crate and so it's particularly important to
avoid unnecessary direct dependencies that could cause a version
conflict in the future.

To help avoid the need for applications to directly depend on
android-activity the Winit crate re-exports the android-activity API
and exposes features to configure the backend so that application crates
can instead rely on Winit to pull in a compatible version of
android-activity. (This way version bumps for android-activity only
need to be synchronized with the Winit crate).

CI now enables the `android-native-activity` feature for testing.

Fixes: emilk#2829
Fixes: emilk#2720
Closes: emilk#2834
@emilk emilk added eframe Relates to epi and eframe egui-winit porblems related to winit dependencies Pull requests that update a dependency file labels Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file eframe Relates to epi and eframe egui-winit porblems related to winit
Projects
None yet
2 participants