inferrna / hello_world_android_egui

Egui + winit + wgpu + android example
MIT License
38 stars 2 forks source link

black screen on real phone #1

Closed sbechet closed 1 year ago

sbechet commented 1 year ago

Hello,

Phone: lineageos ASUS (android 11)

rustup:

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/user/.rustup

installed targets for active toolchain
--------------------------------------

aarch64-linux-android
x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.65.0 (897e37553 2022-11-02)

Debian packages:

ii  android-sdk                           28.0.2+3                         amd64        Software development kit for Android platform
ii  android-sdk-build-tools               29.0.3+3                         amd64        Tools for building Android applications
ii  android-sdk-build-tools-common        29.0.3+3                         all          Tools for building Android applications - Common files
ii  android-sdk-common                    28.0.2+3                         all          Common files of Android SDK base toolset
ii  android-sdk-platform-tools            28.0.2+3                         amd64        Tools for interacting with an Android platform
ii  android-sdk-platform-tools-common     28.0.2+3                         all          Tools for interacting with an Android platform - Common files
ii  google-android-ndk-installer          21d+r1                           amd64        Google Android Native Development Kit (NDK) Installer
ii  libandroid-23-java                    6.0.1+r72-6                      all          Android framework for API Level 23 (6.0 Marshmallow)
$ cargo apk version
cargo-apk 0.9.6

I built and install default debug apk version.

I have only black screen after installation and i'm not an android expert. How can i debug to help?

sbechet commented 1 year ago

same apk tested on samsung tab, same effect. Did you try on real hardware or emulator? Maybe I miss something somewhere?

inferrna commented 1 year ago

Hi, thank you for report. It's working on my Redmi Note 9T, but the same black screen on good old LG G8. I suspect a race condition at initialization stage, will look closer tomorrow. PS: In log I found RustStdoutStderr: thread '<unnamed>' panicked at 'Failed get adapter at src/lib.rs line 198', src/lib.rs:198:24 can you look at your logcat output please?

sbechet commented 1 year ago

Hello,

Yes it seems a thread error. Note: you have got an adapter error, i have a device error?

../..
12-21 12:48:22.529  5128  5153 V winit::platform_impl:..: Mainloop iteration
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Got event: NewEvents(Poll) at src/lib.rs line 107
12-21 12:48:22.530  5128  5153 V winit::platform_impl:..: Handling main event InitWindow
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Got event: Resumed at src/lib.rs line 107
12-21 12:48:22.530  5128  5153 W winit::platform_impl:..: Cannot set window size on Android
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Set to new size: PhysicalSize { width: 1080, height: 2090 } at src/lib.rs line 137
12-21 12:48:22.530  5128  5153 V android_activity::nat..: Attaching input queue to looper
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Got event: MainEventsCleared at src/lib.rs line 107
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Got event: RedrawEventsCleared at src/lib.rs line 107
12-21 12:48:22.530  5128  5153 V android_activity::nat..: Calling post_exec_cmd(InitWindow)
12-21 12:48:22.530  5128  5153 V android_activity::nat..: Post: AppCmd::InitWindow
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Got event: LoopDestroyed at src/lib.rs line 107
12-21 12:48:22.530  5128  5153 W hello_world_android_e..: Recreate platform at src/lib.rs line 159
12-21 12:48:22.531  5128  5153 W hello_world_android_e..: WGPU new surface at src/lib.rs line 170
12-21 12:48:22.536  5128  5153 W hello_world_android_e..: instance request_adapter at src/lib.rs line 173
12-21 12:48:22.540  5128  5153 I Gralloc4: mapper 4.x is not supported
12-21 12:48:22.540  5128  5153 W Gralloc3: mapper 3.x is not supported
12-21 12:48:22.543  5128  5153 W Gralloc4: allocator 3.x is not supported
12-21 12:48:22.543  5128  5153 W Gralloc3: allocator 3.x is not supported
12-21 12:48:22.544  5128  5153 I Gralloc2: Adding additional valid usage bits: 0x202000
12-21 12:48:22.547  5128  5153 W wgpu_hal::vulkan::conv: Unrecognized present mode SHARED_DEMAND_REFRESH
12-21 12:48:22.547  5128  5153 W wgpu_hal::vulkan::conv: Unrecognized present mode SHARED_CONTINUOUS_REFRESH
12-21 12:48:22.547  5128  5153 I wgpu_core::instance: Adapter Vulkan AdapterInfo { name: "Adreno (TM) 512", vendor: ... device: ... device_type: IntegratedGpu, driver: "Qualcomm Technologies Inc. Adreno Vulkan Driver", driver_info: "Driver Build: ...\nDriver Branch: \n", backend: Vulkan }
12-21 12:48:22.547  5128  5153 W hello_world_android_e..: adapter request_device at src/lib.rs line 182
12-21 12:48:22.547  5128  5153 E wgpu::backend::direct: Error in Adapter::request_device: Limit 'max_storage_textures_per_shader_stage' value 8 is better than allowed 4
12-21 12:48:22.548  5128  5152 I RustStdoutStderr: thread '<unnamed>' panicked at 'Failed to request device at src/lib.rs line 195 with error
12-21 12:48:22.548  5128  5152 I RustStdoutStderr: RequestDeviceError', src/lib.rs:192:9
12-21 12:48:22.548  5128  5152 I RustStdoutStderr: stack backtrace:
../..
sbechet commented 1 year ago

On Samsung Galaxy Tab S2:

12-21 13:06:53.241 21587 21604 V winit::platform_impl:..: Mainloop iteration
12-21 13:06:53.241 21587 21604 W hello_world_android_e..: Got event: NewEvents(Poll) at src/lib.rs line 107
12-21 13:06:53.241 21587 21604 V winit::platform_impl:..: Handling main event InitWindow
12-21 13:06:53.241 21587 21604 W hello_world_android_e..: Got event: Resumed at src/lib.rs line 107
12-21 13:06:53.242 21587 21604 W winit::platform_impl:..: Cannot set window size on Android
12-21 13:06:53.242 21587 21604 W hello_world_android_e..: Set to new size: PhysicalSize { width: 1536, height: 2048 } at src/lib.rs line 137
12-21 13:06:53.242 21587 21604 V android_activity::nat..: Attaching input queue to looper
12-21 13:06:53.242 21587 21604 W hello_world_android_e..: Got event: MainEventsCleared at src/lib.rs line 107
12-21 13:06:53.242 21587 21604 W hello_world_android_e..: Got event: RedrawEventsCleared at src/lib.rs line 107
12-21 13:06:53.242 21587 21604 V android_activity::nat..: Calling post_exec_cmd(InitWindow)
12-21 13:06:53.242 21587 21604 V android_activity::nat..: Post: AppCmd::InitWindow
12-21 13:06:53.242 21587 21587 D ViewRootImpl@3c23925[NativeActivity]: ViewRootImpl >> surfaceChanged W=1536, H=2048)
12-21 13:06:53.242 21587 21604 W hello_world_android_e..: Got event: LoopDestroyed at src/lib.rs line 107
12-21 13:06:53.242 21587 21604 W hello_world_android_e..: Recreate platform at src/lib.rs line 159
12-21 13:06:53.243 21587 21604 W hello_world_android_e..: WGPU new surface at src/lib.rs line 170
12-21 13:06:53.244 21587 21604 W hello_world_android_e..: instance request_adapter at src/lib.rs line 173
12-21 13:06:53.244 21587 21604 W wgpu_hal::vulkan::ada..: SPIR-V storage buffer class is not supported, hiding adapter: Adreno (TM) 510
12-21 13:06:53.245 21587 21603 I RustStdoutStderr: thread '<unnamed>' panicked at 'Failed get adapter at src/lib.rs line 180', src/lib.rs:180:24
12-21 13:06:53.245 21587 21603 I RustStdoutStderr: stack backtrace:
12-21 13:06:53.272 21587 21587 D ViewRootImpl@3c23925[NativeActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1536, 2048) ci=Rect(0, 48 - 0, 0) vi=Rect(0, 48 - 0, 0) or=1
12-21 13:06:53.272 21587 21587 D ViewRootImpl@3c23925[NativeActivity]: MSG_WINDOW_FOCUS_CHANGED 1
12-21 13:06:53.272 21587 21587 D android_activity::nat..: WindowFocusChanged: 0x7f850bed80 -- 1
12-21 13:06:53.273 21587 21587 V InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@8df67dd nm : rust.hello_world_android_egui ic=null
12-21 13:06:53.273 21587 21587 I InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
12-21 13:06:53.278 21587 21600 D InputTransport: Input channel constructed: fd=73
12-21 13:06:53.278 21587 21587 V InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@ab2bf52 nm : rust.hello_world_android_egui ic=null
inferrna commented 1 year ago

Yes, there are different errors. Adapter error means wgpu was unable to find an appropriate adapter for Vulkan nor OpenGL. The device error looks much more promising - at least we can try tune some options to fit into its capabilities. I changed limits to

limits: wgpu::Limits::downlevel_defaults(),

try it now.

sbechet commented 1 year ago

Hello inferrna,

Good news with wgpu::Limits::downlevel_defaults(): egui is now visible on my lineageos ASUS phone nevertheless, egui use the top half of the screen. But it is certainly another bug.

For the Samsung Galaxy Tab S2 nothing on the screen yet but I see this log: 12-23 20:42:51.728 1238 3225 D GameManagerService: identifyGamePackage. rust.hello_world_android_egui. I'll try to disable GameManagerService to see if it is better.

sbechet commented 1 year ago

For the Samsung Galaxy Tab S2 nothing on the screen yet but I see this log: 12-23 20:42:51.728 1238 3225 D GameManagerService: identifyGamePackage. rust.hello_world_android_egui. I'll try to disable GameManagerService to see if it is better.

Impossible to remove this service... I removed all packages i can using uad.

In fact, when i read again 12-21 13:06:53.244 21587 21604 W wgpu_hal::vulkan::ada..: SPIR-V storage buffer class is not supported, hiding adapter: Adreno (TM) 510 seems strange no?

sbechet commented 1 year ago

Galaxy Tab S2, found some errors at start:

12-23 21:14:08.026  5405  5405 E Zygote  : v2
...
12-23 21:14:08.028  5405  5405 E Zygote  : accessInfo : 0
...
12-23 21:14:08.258  5405  5443 W hello_world_android_e..: Winit build window at src/lib.rs line 63
12-23 21:14:08.258  5405  5443 W hello_world_android_e..: WGPU new instance at src/lib.rs line 79
12-23 21:14:08.259  5405  5443 E vulkan  : invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call
12-23 21:14:08.259  5405  5443 E vulkan  : invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call
inferrna commented 1 year ago

SPIR-V storage buffer class is not supported, hiding adapter: Adreno (TM) 510 comes from https://wgpu.rs/doc/src/wgpu_hal/vulkan/adapter.rs.html#961 Unfortunately, WGPU targeting newer stack, than old devices can afford.

Regarding your half-screen problem with ASUS - try to play with code on lines 170~220 of lib.rs. Also look into logcat for this

"Set to new size: {:?} at {} line {}",

to see screen size it tries to use.

sbechet commented 1 year ago

Hello inferrna, thank you very much for your help. I think we can't do more for this issue. Do you think i can close it ? Thx!

inferrna commented 1 year ago

Ok