Universal-Debloater-Alliance / universal-android-debloater-next-generation

Cross-platform GUI written in Rust using ADB to debloat non-rooted Android devices. Improve your privacy, the security and battery life of your device.
GNU General Public License v3.0
1.74k stars 64 forks source link

bug(crash): `panick in main: called Option::unwrap() on a None value` #432

Open xelxebar opened 2 months ago

xelxebar commented 2 months ago

Describe the bug

Overview

The Nix package for 1.0.3 is crashing with the below error. Is anyone here able to reproduce?

[nix-shell:~]$ RUST_BACKTRACE=full ./uag-ng.sh
2024-04-27 17:57:14 WARN  [/build/universal-android-debloater-1.0.3-vendor.tar.gz/winit/src/platform_impl/linux/x11/xdisplay.rs:124] error setting XSETTINGS; Xft options won't reload automatically
2024-04-27 17:57:14 WARN  [/build/universal-android-debloater-1.0.3-vendor.tar.gz/wgpu-hal/src/gles/egl.rs:788] EGL_MESA_platform_surfaceless not available. Using default platform
thread 'main' panicked at /build/universal-android-debloater-1.0.3-vendor.tar.gz/wgpu-hal/src/gles/egl.rs:789:88:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x5564f3e0dee8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d3e31f1809523c
   1:     0x5564f3ac5ac0 - core::fmt::write::h76573a5842288faa
   2:     0x5564f3e23b14 - std::io::Write::write_fmt::hb095d534967ab243
   3:     0x5564f3e0e95e - std::sys_common::backtrace::print::h73765b495122298a
   4:     0x5564f3e0e655 - std::panicking::default_hook::{{closure}}::hfad133b7877f7d1a
   5:     0x5564f3e0f4ce - std::panicking::rust_panic_with_hook::h03308f3977d70e82
   6:     0x5564f3e0ef88 - std::panicking::begin_panic_handler::{{closure}}::h6543c8dd74f459e9
   7:     0x5564f3e0ef16 - std::sys_common::backtrace::__rust_end_short_backtrace::h68617e661e847078
   8:     0x5564f3e0ef03 - rust_begin_unwind
   9:     0x5564f3abca54 - core::panicking::panic_fmt::hf7f647d933c4266a
  10:     0x5564f3abda72 - core::panicking::panic::h423064a40da58821
  11:     0x5564f3ac85d5 - core::option::unwrap_failed::hffb1e9e838106d36
  12:     0x5564f4164a68 - wgpu_core::instance::Instance::new::h45a023e4468c6ba4
  13:     0x5564f3a489c5 - futures_executor::local_pool::block_on::h81a2843031214e94
  14:     0x5564f3f2b4ba - <iced_renderer::compositor::Compositor as iced_graphics::compositor::Compositor>::new::h11f9aa80284f287a
  15:     0x5564f3f97482 - iced_winit::application::run::hb1ecb9c33ec37eba
  16:     0x5564f3fd034e - uad_ng::main::h22da11ae92f257d4
  17:     0x5564f3f8eb87 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd7031090c0c5e9e0
  18:     0x5564f3fcf593 - main
  19:     0x7f1835b7410e - __libc_start_call_main
  20:     0x7f1835b741c9 - __libc_start_main@@GLIBC_2.34
  21:     0x5564f3a47c65 - _start
  22:                0x0 - <unknown>

Version Information

[nix-shell:~]$ nix-info --markdown --host-os
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.7, Guix System, noversion, nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.16.1`
 - channels(x): `"nixpkgs-23.11pre505289.57695599bdc"`
 - nixpkgs: `/home/x/.nix-defexpr/channels/nixpkgs`

[nix-shell:~]$ nix-env -qaP universal-android-debloater
nixpkgs.universal-android-debloater  universal-android-debloater-1.0.3

Expected behavior

Application should boot.

You have a solution?

No response

Provide logs

UAD_20240427.log

Acknowledgements

lavafroth commented 2 months ago

I'm not sure where you got that ./uad-ng.sh file because we do not serve a shell script. If you ran something like nix shell nixpkgs#universal-android-debloater to land into a devshell, you'll need to run uad-ng.

We are aware of the fact that the nixpkgs derivation does not link libwayland but that should not affect you since you're using X.

You can check out the nix-flake branch I've been working on.

git clone https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation -b nix-flake
cd universal-android-debloater-next-generation
nix develop
cargo run
xelxebar commented 2 months ago

@lavafroth Uh, I forgot to sanitize ./uad-ng.sh out. It's a temporary wrapper fix. Something at startup wants libxkbcommon-x11.so but the nix wrapper doesn't have it in LD_LIBRARY_PATH, causing initialization to fall over. I didn't intend to mix issues here, though.

Seeing the same panic on the nix-flake branch, unfortunately:

x@myyrix ~/universal-android-debloater-next-generation$ git rev-parse HEAD
1adf69bd8d358c6393bd487ef56bee9bb0924ff2
x@myyrix ~/universal-android-debloater-next-generation$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/uad-ng`
2024-05-01 17:00:58 WARN  [/home/x/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/x11/xdisplay.rs:124] error setting XSETTINGS; Xft options won't reload automatically
2024-05-01 17:00:58 WARN  [/home/x/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.3/src/gles/egl.rs:788] EGL_MESA_platform_surfaceless not available. Using default platform
thread 'main' panicked at /home/x/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.3/src/gles/egl.rs:789:88:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Frigyes06 commented 2 months ago

If I read that log correctly, this panic happens inside the wgpu-hal crate however. So maybe it'd be beneficial to open an issue for them?

xelxebar commented 2 months ago

@Frigyes06 Maybe? It's happening at the line below in wgpu-hal. They're explicitly performing an unsafe operation which I assume is intentional. Possible that we're not correctly setting up the display environment or something?

            if let (Some(library), Some(egl)) = (wayland_library, egl1_5) {
            ...
            } else {
                log::warn!("EGL_MESA_platform_surfaceless not available. Using default platform");
                let display = unsafe { egl.get_display(khronos_egl::DEFAULT_DISPLAY) }.unwrap();   // <-- this line
                (display, None, WindowKind::Unknown)
            };