PabloMK7 / citra

A Nintendo 3DS Emulator
GNU General Public License v2.0
3.76k stars 637 forks source link

android: When rotating the device 180° the emulator crashes #188

Open newhinton opened 4 months ago

newhinton commented 4 months ago

Is there an existing issue for this?

Affected Build(s)

93025c95f2ce4baed37a7b587236f12ef667c540

Description of Issue

With the new device orientation feature, the emulator crashes when the device rotates 180° (landscape) Both automatic and landscape screen orientations cause this crash.

From what i can see, this originates from the core, not my changes. I also have experienced other crashes like when the power savings mode restarts, but those have been hard to reproduce.

Expected Behavior

No Crash.

Reproduction Steps

Log File

2024-07-14 13:22:02.259 19493-19522 CitraNative             org.citra.citra_emu.canary.debug     E  [  11.430342] Service.FS <Error> ./core/file_sys/archive_backend.h:GetOpenDelayNs:209: Delay generator was not initalized. Using default
2024-07-14 13:22:02.260 19493-19522 CitraNative             org.citra.citra_emu.canary.debug     W  [  11.430707] Service.FS <Warning> core/file_sys/archive_ncch.cpp:OpenFile:166: Bad Word List file missing. Loading open source replacement from memory
2024-07-14 13:22:02.527 19493-19493 BufferQueueProducer     org.citra.citra_emu.canary.debug     E  [SurfaceView[org.citra.citra_emu.canary.debug/org.citra.citra_emu.activities.EmulationActivity]#5(BLAST Consumer)5](id:4c2500000005,api:1,p:19493,c:19493) connect: already connected (cur=1 req=1)
2024-07-14 13:22:02.527 19493-19493 vulkan                  org.citra.citra_emu.canary.debug     E  native_window_api_connect() failed: Invalid argument (-22)
2024-07-14 13:22:02.527 19493-19522 CitraNative             org.citra.citra_emu.canary.debug     W  [  11.430707] Service.FS <Warning> core/file_sys/archive_ncch.cpp:OpenFile:166: Bad Word List file missing. Loading open source replacement from memory
2024-07-14 13:22:02.527 19493-19522 CitraNative             org.citra.citra_emu.canary.debug     A  [  11.698133] Render.Vulkan <Critical> video_core/renderer_vulkan/vk_platform.cpp:CreateSurface:187: Failed to initialize Android surface
2024-07-14 13:22:02.527 19493-19522 CitraNative             org.citra.citra_emu.canary.debug     A  [  11.698145] Debug <Critical> video_core/renderer_vulkan/vk_platform.cpp:operator():188: Unreachable code!
2024-07-14 13:22:02.528 19493-19493 libc                    org.citra.citra_emu.canary.debug     A  Fatal signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0xc33a29bf4fac in tid 19493 (mu.canary.debug), pid 19493 (mu.canary.debug)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A  Cmdline: org.citra.citra_emu.canary.debug
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A  pid: 19493, tid: 19493, name: mu.canary.debug  >>> org.citra.citra_emu.canary.debug <<<
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #00 pc 00000000019b1fac  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/lib/arm64/libcitra-android.so (BuildId: 8d43a94f83253a3c7d0107494c3fd626a995948e)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #01 pc 00000000019b1f5c  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/lib/arm64/libcitra-android.so (Vulkan::CreateSurface(vk::Instance, Frontend::EmuWindow const&)+292) (BuildId: 8d43a94f83253a3c7d0107494c3fd626a995948e)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #02 pc 00000000019c3604  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/lib/arm64/libcitra-android.so (Vulkan::PresentWindow::NotifySurfaceChanged()+36) (BuildId: 8d43a94f83253a3c7d0107494c3fd626a995948e)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #03 pc 0000000001456e10  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/lib/arm64/libcitra-android.so (Java_org_citra_citra_1emu_NativeLibrary_surfaceChanged+108) (BuildId: 8d43a94f83253a3c7d0107494c3fd626a995948e)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #09 pc 0000000000301534  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (org.citra.citra_emu.fragments.EmulationFragment$EmulationState.runWithValidSurface+0)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #14 pc 00000000003013f4  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (org.citra.citra_emu.fragments.EmulationFragment$EmulationState.newSurface+0)
2024-07-14 13:22:02.938 19767-19767 DEBUG                   pid-19767                            A        #19 pc 0000000000304c34  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (org.citra.citra_emu.fragments.EmulationFragment.surfaceChanged+0)
2024-07-14 13:22:02.939 19767-19767 DEBUG                   pid-19767                            A        #40 pc 0000000000141b88  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild+0)
2024-07-14 13:22:02.939 19767-19767 DEBUG                   pid-19767                            A        #45 pc 0000000000142588  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild+0)
2024-07-14 13:22:02.939 19767-19767 DEBUG                   pid-19767                            A        #50 pc 0000000000142508  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout+0)
2024-07-14 13:22:02.939 19767-19767 DEBUG                   pid-19767                            A        #66 pc 0000000000168d9c  /data/app/~~vIPVhQFEg_mAgfJxotbqqA==/org.citra.citra_emu.canary.debug-oR0nthU32eR3m88laLPL7g==/base.apk (androidx.drawerlayout.widget.DrawerLayout.onLayout+0)

System Configuration

CPU: Google Tensor G2 (Pixel 7) GPU/Driver: RAM: 4Gb OS: GrapheneOS (android 14)

PabloMK7 commented 4 months ago

This is something you will have to look into, and provide as much context as possible. Seems to be related to vulkan. Otherwise I will have to revert the commit until it is fixed.

Enable the debug renderer and try again.

newhinton commented 4 months ago

As far as i can tell, the error is the same with the debug renderer. Does that output to a different place than logcat?

Just as a sanity check: This also happens with the "original" orientation which corresponds to ActivityInfo.SCREEN_ORIENTATION_USER (2). Though there the user has to press that little orientation-change button that pops up, after which citra crashes. So this bug existed beforehand, just the new settings really exacerbate this issue.

One option would be to change the options to not use SCREEN_ORIENTATION_SENSOR_LANDSCAPE but SCREEN_ORIENTATION_LANDSCAPE and newly SCREEN_ORIENTATION_REVERSE_LANDSCAPE AND remove the automatic variant. This should prevent the device from automatically rotating, but really makes it more convoluted.

However, that solution has the benefit that we can change this any time we want. If that bug gets fixed, we can just change it back. Users that made use of the then-missing options will not know there was a change, until they change it. Their original choice will still work just as fine. It's just not selectable anymore.

fight-fly commented 4 months ago

Hey guys,

have a look https://github.com/PabloMK7/citra/pull/56

it may help.

fight-fly commented 4 months ago

If this issue can be closed in the future, then #61 may also be closed. Please test #61 on your new PR.