-
Notifications
You must be signed in to change notification settings - Fork 109
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
Add ndk-context. #223
Add ndk-context. #223
Conversation
As this PR stands, winit will not be able to replace ndk-glue with ndk-context, but maybe this is intended. Besides that this should be enough for many other creates, including openxrs. |
This is indeed intended. winit (and presumably a game engine) is highly tied to the runtime and cargo-apk. I think this should be enough for most crates wanting to add some android support. If there are crates for which this isn't sufficient we can collect the exact reasons why not in an issue and then see if we have to take further steps. |
Ping @MarijnS95 |
@msiglreith looks like @MarijnS95 is on vaccation or something. what are your thoughts on this PR? |
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.
API-wise it looks good to me. The crate should be listed in the README and probably also include a section regarding ndk-context
vs ndk-glue
somewhere
So wondering if we shoud remove the |
Yep, we should deprecate it [0] shows how to access it using the jni. |
Not anymore 😉. Taking a (still rather short) break from open source was well needed. I thought the idea was to remove all |
Regarding this, since there don't seem to be many users of it after switching everyone over to Maybe good idea to document for most of these popular crates - https://crates.io/crates/ndk-glue/reverse_dependencies - what exactly they need from |
Yes, think removing the static So in general are you ok with the ndk-context approach to partly solving this problem? |
This reverts commit bb117f0.
So removed the NATIVE_ACTIVITY global as I think this is one we agree on and is worth doing. |
https://github.com/MarijnS95/android-ndk-rs/compare/anativeactivity-instance @dvc94ch This is my draft idea for removing fallible |
@MarijnS95 that looks good, I think it's an improvement for some use cases. But in general I still think we should try to discourage the use of ndk-glue unless it's absolutely necessary. If you open a PR we can merge it and I'll change jni-audio back to using ndk-context. |
I think both PRs are a great step in that direction 😉. Mine still has some open questions though:
Will need some more thoughts, I think I'll get this merged + released + backported ASAP, then PR the migration to most obvious crates and see where to move next. |
Looks like GH comment notifications are all over the place. Are we removing (Sorry about closing this, ctrl+enter vs ctrl+shift+enter muscle memory isn't what it's supposed to be) |
Co-authored-by: Marijn Suijten <marijns95@gmail.com>
Do we need a changelog for the new crate, and the changes listed in the |
Think we can hold off for with releasing until your PR lands, I removed my changes. Got to go afk for a while, will add a CHANGELOG afterwards. |
We can do a non-breaking patch release (same for the backports) now with |
In order to show that [#223] solves our problem ([#211]) with multiple ndk-glue versions in tree, all having their own `static` globals, backport the `ndk-context` initialization to `ndk-glue 0.5` so that everyone on `winit 0.26` (pending a `winit 0.27` release) can be compatible with other crates using the Java VM and/or Android Context. These crates will need to migrate to `ndk-context` first though. [#211]: #211 [#223]: #223
The crate oboe requires the VM and Context pointers, but also the sdk version. Is there a way of getting the sdk version from the context pointer? |
In order to show that [#223] solves our problem ([#211]) with multiple ndk-glue versions in tree, all having their own `static` globals, backport the `ndk-context` initialization to `ndk-glue 0.5` so that everyone on `winit 0.26` (pending a `winit 0.27` release) can be compatible with other crates using the Java VM and/or Android Context. These crates will need to migrate to `ndk-context` first though. [#211]: #211 [#223]: #223
yes, should be possible, although will require fiddling a bit with the jni. |
@dvc94ch Oh that's great, thanks! |
`ndk-glue` suffers one fatal flaw: it's "only" supposed to be used by the crate providing `fn main()` and only supposed to end up in the dependency graph once as it has `static` globals which get duplicated across versions. In the current case with `winit 0.26` still on `ndk-glue 0.5` but `app_dirs2` booted from `0.4` to `0.6` it'll always panic in `fn native_activity()` as the `static` globals on these versions are not initialized: app-dirs-rs#18 (comment) Introducing `ndk-context`: a crate that holds these `static`s, with the intention/premise to not see a breaking release /ever/ and make this a problem of the past. The crate is currently initialized with the VM and Android Context on `ndk-glue` 0.5.1 and 0.6.1 making it compatible with whatever is current, and the possibility for backporting to older `ndk-glue` versions too. See also: rust-mobile/ndk#211 rust-mobile/ndk#223
In order to show that [#223] solves our problem ([#211]) with multiple ndk-glue versions in tree, all having their own `static` globals, backport the `ndk-context` initialization to `ndk-glue 0.4` so that everyone on this older crate can be compatible with other crates using the Java VM and/or Android Context. These crates will need to migrate to `ndk-context` first though. [#211]: #211 [#223]: #223
`ndk-glue` suffers one fatal flaw: it's "only" supposed to be used by the crate providing `fn main()` and only supposed to end up in the dependency graph once as it has `static` globals which get duplicated across versions. In the current case with `winit 0.26` still on `ndk-glue 0.5` but `cpal` on `ndk-glue 0.6` it'll always panic in `fn native_activity()` as the `static` globals on this version is not initialized. Introducing `ndk-context`: a crate that holds these `static`s, with the intention/premise to not see a breaking release /ever/ and make this a problem of the past. The crate is currently initialized with the VM and Android Context on `ndk-glue` 0.5.1 and 0.6.1 (0.4.1 pending) making it compatible with whatever is current, and the possibility for backporting to older `ndk-glue` versions too. See also: rust-mobile/ndk#211 rust-mobile/ndk#223
`ndk-glue` suffers one fatal flaw: it's "only" supposed to be used by the crate providing `fn main()` and only supposed to end up in the dependency graph once as it has `static` globals which get duplicated across versions. In the current case with `winit 0.26` still on `ndk-glue 0.5` but `cpal` on `ndk-glue 0.6` it'll always panic in `fn native_activity()` as the `static` globals on this version is not initialized. Introducing `ndk-context`: a crate that holds these `static`s, with the intention/premise to not see a breaking release /ever/ and make this a problem of the past. The crate is currently initialized with the VM and Android Context on `ndk-glue` 0.5.1 and 0.6.1 (0.4.1 pending) making it compatible with whatever is current, and the possibility for backporting to older `ndk-glue` versions too. See also: rust-mobile/ndk#211 rust-mobile/ndk#223
`ndk-glue` suffers one fatal flaw: it's "only" supposed to be used by the crate providing `fn main()` and only supposed to end up in the dependency graph once as it has `static` globals which get duplicated across versions. In the current case with `winit 0.26` still on `ndk-glue 0.5` but `cpal` on `ndk-glue 0.6` it'll always panic in `fn native_activity()` as the `static` globals on this version is not initialized. Introducing `ndk-context`: a crate that holds these `static`s, with the intention/premise to not see a breaking release /ever/ and make this a problem of the past. The crate is currently initialized with the VM and Android Context on `ndk-glue` 0.5.1 and 0.6.1 (0.4.1 pending) making it compatible with whatever is current, and the possibility for backporting to older `ndk-glue` versions too. See also: rust-mobile/ndk#211 rust-mobile/ndk#223
In order to show that [#223] solves our problem ([#211]) with multiple ndk-glue versions in tree, all having their own `static` globals, backport the `ndk-context` initialization to `ndk-glue 0.4` so that everyone on this older crate can be compatible with other crates using the Java VM and/or Android Context. These crates will need to migrate to `ndk-context` first though. [#211]: #211 [#223]: #223
Closes #211