app-dirs-rs / app_dirs2

A maintained fork of the app-dirs-rs project.
MIT License
35 stars 7 forks source link

android: Migrate from `ndk-glue` to `ndk-context` #19

Closed MarijnS95 closed 2 years ago

MarijnS95 commented 2 years ago

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: https://github.com/app-dirs-rs/app_dirs2/pull/18#issuecomment-1029026065

Introducing ndk-context: a crate that holds these statics, 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: https://github.com/rust-windowing/android-ndk-rs/issues/211 https://github.com/rust-windowing/android-ndk-rs/pull/223

kornelski commented 2 years ago

Thanks