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

Basic android event loop 2.0 #2

Conversation

dvc94ch
Copy link

@dvc94ch dvc94ch commented Feb 5, 2020

  • Tested on all platforms changed
  • 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
  • Created an example program if it would help users understand this functionality

@goddessfreya
Copy link
Owner

Are there are still issues with orientation changes? Can we get android added to the CI?

@dvc94ch
Copy link
Author

dvc94ch commented Feb 6, 2020

Are there are still issues with orientation changes?

Not yet. Had to get it working again with the 0.23 branch first, I'll look into it next.

Copy link
Owner

@goddessfreya goddessfreya left a comment

Choose a reason for hiding this comment

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

CHANGELOG.md Outdated Show resolved Hide resolved
src/platform_impl/linux/wayland/event_loop.rs Show resolved Hide resolved
@dvc94ch
Copy link
Author

dvc94ch commented Feb 8, 2020

This is a pretty important one that's not fixed yet rust-windowing#789

@dvc94ch
Copy link
Author

dvc94ch commented Feb 10, 2020

cc @katyo

@katyo
Copy link

katyo commented Feb 12, 2020

@dvc94ch I completely confused... How can I test it for now?

Copy link
Owner

@goddessfreya goddessfreya left a comment

Choose a reason for hiding this comment

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

Needs a rebase

@dvc94ch dvc94ch force-pushed the winit-glutin-next-android branch 2 times, most recently from 4759911 to 8cc2fc3 Compare February 12, 2020 09:51
@dvc94ch
Copy link
Author

dvc94ch commented Feb 12, 2020

@katyo I created a repo with an example called android-no-glue.
first you need to clone the following repos:

then you need to install the new cargo-ndk:

cargo install --path android-ndk-rs/cargo-ndk

then you can build and run the android-no-glue example with:

cargo ndk run --target aarch64-linux-android

@dvc94ch
Copy link
Author

dvc94ch commented Feb 12, 2020

@katyo did you get it to work? cargo-ndk still needs some work, some values are still hardcoded instead of parsed from the manifest, it doesn't resolving libraries recursively, doesn't emit fat binaries and doesn't support examples that work on desktop and mobile (as cargo does not support target specific crate-type)

@katyo
Copy link

katyo commented Feb 13, 2020

@dvc94ch Thanks for expl.
Pls, fix winit-windowing to rust-windowing in repository urls

@katyo
Copy link

katyo commented Feb 13, 2020

Unfortunately I cannot get it work due to linking errors:

error: linking with `...androidenv/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang` failed: exit code: 1

And error like a:

...android/android-no-glue/target/aarch64-linux-android/debug/deps/liblibloading-b99b21efde076db4.rlib: error adding symbols: File in wrong format

Same error with "--target arm-linux-androideabi":

...androidenv/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: ...android/android-no-glue/target/arm-linux-androideabi/debug/deps/liblibloading-3d5325302b343522.rlib(global_static.o): incompatible target
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems something wrong with cargo ndk.
But I already used this tool for building shared libs for android and it works.

@dvc94ch
Copy link
Author

dvc94ch commented Feb 13, 2020

cargo-ndk is ridiculously simple, the entire build logic is below, so I'm a bit confused how that's happening. Can you post the entire build log?

if let Some(triple) = target {
        let clang = ndk.clang(triple, manifest.target_sdk_version)?;
        cargo.env(cargo_env_target_cfg("LINKER", triple), &clang);

        let ar = ndk.toolchain_bin("ar", triple)?;
        cargo.env(cargo_env_target_cfg("AR", triple), &ar);
    }

    if cargo_cmd == "build" || cargo_cmd == "run" {
        cargo.arg("build").args(&cargo_args).status()?;
    }

EDIT: Did a clean build and there does seem to be some issues

@katyo
Copy link

katyo commented Feb 13, 2020

I may mistake but it seems some important env vars is unset:

TARGET = Some("armv7-linux-androideabi")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-linux-gnu")
CC_armv7-linux-androideabi = None # should be set!
CC_armv7_linux_androideabi = None
TARGET_CC = None
CC = Some("gcc") # wrong value!
CFLAGS_armv7-linux-androideabi = None
CFLAGS_armv7_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = None

As I know the cargo apk sets CC with appropriate C compiler.

@dvc94ch
Copy link
Author

dvc94ch commented Feb 13, 2020

Sry I'm a bit slow today, I've got a hangover. cargo-ndk is updated

@katyo
Copy link

katyo commented Feb 13, 2020

@dvc94ch How can I specify min sdk version?

@dvc94ch
Copy link
Author

dvc94ch commented Feb 13, 2020

@katyo Just finished implementing Cargo.toml parsing and fat binaries. It should work the same as cargo-apk. Only things missing is running bin/examples and porting your patch to recursively find libraries.

@katyo
Copy link

katyo commented Feb 13, 2020

I able to build it but I have an error:

    Finished dev [unoptimized + debuginfo] target(s) in 24.10s
 'lib/arm64-v8a/libandroid_no_glue.so'...
Verifying alignment of ...android/android-no-glue/target/debug/ndk/android-no-glue.apk (4)...
      49 AndroidManifest.xml (OK - compressed)
     955 lib/arm64-v8a/libandroid_no_glue.so (OK - compressed)
Verification succesful
Error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })

The apk is built but it seems the signing failed so I cannot install it:

adb: failed to install target/debug/ndk/android-no-glue.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl534534027.tmp/base.apk: Attempt to get length of null array]

@dvc94ch
Copy link
Author

dvc94ch commented Feb 13, 2020

Mmh, what os are you using? Looks like we're nearly there :) I rebased cargo-ndk as it's feature complete. Now onto ironing out the bugs...

What happens if you update to latest master and remove ~/.android/debug.keystore?

Finished dev [unoptimized + debuginfo] target(s) in 0.02s
 'lib/arm64-v8a/libhello_world.so'...
Verifying alignment of /home/dvc/android/android-ndk-rs/target/debug/ndk/examples/hello_world/android-examples.apk (4)...
      49 AndroidManifest.xml (OK - compressed)
     961 lib/arm64-v8a/libhello_world.so (OK - compressed)
Verification succesful
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
	for: CN=Android Debug, O=Android, C=US
[Storing /home/dvc/.android/debug.keystore]

@katyo
Copy link

katyo commented Feb 13, 2020

I use nixos, if this matter.

Verifying alignment of ...android/android-no-glue/target/debug/ndk/android-no-glue.apk (4)...
      49 AndroidManifest.xml (OK - compressed)
     955 lib/arm64-v8a/libandroid_no_glue.so (OK - compressed)
Verification succesful
Generating 2 048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10 000 days
        for: CN=Android Debug, O=Android, C=US
[Storing /home/kayo/.android/debug.keystore]

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /home/kayo/.android/debug.keystore -destkeystore /home/kayo/.android/debug.keystore -deststoretype pkcs12".
Error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })

@katyo
Copy link

katyo commented Feb 13, 2020

It still not installable:

$ adb install target/debug/ndk/android-no-glue.apk
adb: failed to install target/debug/ndk/android-no-glue.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl169659180.tmp/base.apk: Attempt to get length of null array]

[nix-shell:...android/android-no-glue]$ l target/debug/ndk/*.apk
-rw-r--r-- 1 kayo users 3,0M feb 14 00:25 target/debug/ndk/android-no-glue.apk
-rw-r--r-- 1 kayo users 3,0M feb 14 00:25 target/debug/ndk/android-no-glue-unaligned.apk

@dvc94ch
Copy link
Author

dvc94ch commented Feb 13, 2020

The weird thing is that we check that apksigner exists and then we fail with file not found. Is it possible that apksigner is a symlink? If that's the case it should be fixed now

@katyo
Copy link

katyo commented Feb 13, 2020

Oh, It seems I forget patch android sdk executables after upgrading :)
It works!

@dvc94ch dvc94ch force-pushed the winit-glutin-next-android branch 4 times, most recently from 3fbabd3 to 66566ab Compare February 17, 2020 17:45
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Copy link
Owner

@goddessfreya goddessfreya left a comment

Choose a reason for hiding this comment

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

Can winit's readme be amended with instructions for building the examples on android?

@dvc94ch
Copy link
Author

dvc94ch commented Feb 17, 2020

Due to rust-lang/cargo#4881 saddly there's no good way to do it. I considered fixing it but it would likely be years behind a feature gate if the PR even gets accepted, so I decided it's not worth it.

@dvc94ch
Copy link
Author

dvc94ch commented Apr 21, 2020

@Osspial so this one builds on the glutin 0.23 work. but it doesn't look like that's going anywhere for the time being as the windows and mac os x backends are missing. Should I backport it to winit master?

@Osspial
Copy link

Osspial commented Apr 21, 2020

@Osspial so this one builds on the glutin 0.23 work. but it doesn't look like that's going anywhere for the time being as the windows and mac os x backends are missing. Should I backport it to winit master?

👍 that seems like the right call.

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.

4 participants