mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.42k stars 747 forks source link

mgba-qt doesn't work in Wayland #2190

Closed jiangzhengwenjz closed 1 year ago

jiangzhengwenjz commented 3 years ago

Platform: Fedora 34 workstation (gcc 11.1.1-1) Versions being tested: 86ec2d4 & 2d87cc1 (HEAD of master & 0.9)

The executables and libraries can be compiled and installed fine but mgba-qt simply doesn't work for me.

~Here's what happened when I'm using XORG GNOME: https://streamable.com/wi3h0a (the terminal shows SDL Audio: Could not open SDL sound system) -> and audio won't play~

And when I select GNOME (Wayland? ), the program reacts very differently. Before loading the ROM: Imgur After: Imgur And if you load the ROM again, it will result in a segmentation fault. The audio is playing fine in this case.


Update May 18: In Xorg it's working under unknown situations, tested 3 times (in 3 different sessions) and it's whitescreen -> flawless -> whitescreen. It's likely GNOME's fault so the problem is probably only for Wayland.


On the contrary, the SDL version is always working fine on my machine.

endrift commented 3 years ago

Please attach the report file generated by the report bug screen

jiangzhengwenjz commented 3 years ago

https://www.mediafire.com/file/8uc4f2poyeguhhn/report.zip/file

Testsr commented 2 years ago

Copy of the above link's file. report.zip

endrift commented 2 years ago

This is a duplicate of #1837 I believe, though that one got closed since the person who was "helping" me debug it on Sway was a huge asshole and didn't actually help.

HorstBaerbel commented 2 years ago

I can't even compile m-gba on Fedora 35. I installed a bunch of libraries, but ended up with:

Make Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LibLZMA (missing: LIBLZMA_LIBRARY LIBLZMA_INCLUDE_DIR
  LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindLibLZMA.cmake:89 (find_package_handle_standard_args)
  /usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  /usr/lib64/cmake/minizip/minizip-config.cmake:39 (find_dependency)
  src/platform/cmake/FindFeature.cmake:15 (find_package)
  CMakeLists.txt:478 (find_feature)

Command line: cmake -DCMAKE_CONFIG=Release -DUSE_ZLIB=OFF -DUSE_LZMA=OFF ..

Any idea what could be wrong? There's no "liblzma-devel" I could install...

jiangzhengwenjz commented 2 years ago

I can't even compile m-gba on Fedora 35. I installed a bunch of libraries, but ended up with:

Make Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LibLZMA (missing: LIBLZMA_LIBRARY LIBLZMA_INCLUDE_DIR
  LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindLibLZMA.cmake:89 (find_package_handle_standard_args)
  /usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  /usr/lib64/cmake/minizip/minizip-config.cmake:39 (find_dependency)
  src/platform/cmake/FindFeature.cmake:15 (find_package)
  CMakeLists.txt:478 (find_feature)

Command line: cmake -DCMAKE_CONFIG=Release -DUSE_ZLIB=OFF -DUSE_LZMA=OFF ..

Any idea what could be wrong? There's no "liblzma-devel" I could install...

Try lib64lzma-devel?

HorstBaerbel commented 2 years ago

Thanks. Afair it did not show up in dnf for me, but will check again tomorrow...

endrift commented 2 years ago

Try -DUSE_MINIZIP=OFF, since this looks like that's trying to pull in libLZMA for some reason. mGBA's USE_LZMA uses a version of the LZMA SDK that's bundled so it shouldn't do this.

HorstBaerbel commented 2 years ago

I just checked. lib64lzma-devel is not available via dnf. -DUSE_MINIZIP=OFF leads to:

CMake Error at /usr/lib64/cmake/libzip/libzip-targets.cmake:92 (message):
  The imported target "libzip::zipcmp" references the file

     "/usr/bin/zipcmp"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib64/cmake/libzip/libzip-targets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib64/cmake/libzip/libzip-config.cmake:42 (include)
  src/platform/cmake/FindFeature.cmake:15 (find_package)
  CMakeLists.txt:480 (find_feature)
endrift commented 2 years ago

That's an issue with libzip's CMake packaging. You'll need to install zipcmp and another tool. I don't know what the packages are called on Fedora.

HorstBaerbel commented 2 years ago

Installing "libzip-tools" and -DUSE_MINIZIP=OFF did the trick. Thanks!

HorstBaerbel commented 2 years ago

The SDL2 version seems to work, but the Qt version does not load the .gba or .elf from the command line or the menu

HorstBaerbel commented 2 years ago

If I can help with logs or debugging, tell me, endrift. I'll have some time on and off in the next days...

HorstBaerbel commented 2 years ago

According to my tests (newest git):

HorstBaerbel commented 2 years ago

This is with useShareWidget=true

https://user-images.githubusercontent.com/1310747/150640386-23ac9b94-9a5f-4532-911e-7be2fdda7a0f.mp4

HorstBaerbel commented 2 years ago

With useShareWidget=false

https://user-images.githubusercontent.com/1310747/150640491-f2d2c2e0-4d8e-4b72-aec6-b02dc20d0123.mp4

endrift commented 2 years ago

Looks like the OpenGL context is swapping, but nothing is being drawn to it for some reason. Hm...

HorstBaerbel commented 2 years ago

I was playing around a bit:

jsteinaker commented 2 years ago

Looks like the OpenGL context is swapping, but nothing is being drawn to it for some reason. Hm...

Can reproduce it here, on updated Arch Linux, KDE Plasma running on Wayland. If I launch the emulator from a terminal window, it prints the line

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

Software (Qt) renderer works perfect and that line doesn't get printed to the terminal, but it's obviously CPU-intensive.

HorstBaerbel commented 2 years ago

When trying to switch the Display driver in settings I also get:

qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

This a fresh Fedora 36 install running Wayland. I think I compiled with out OpenGL support.

endrift commented 2 years ago

Those warnings are unrelated. I have a solution I'm working on right now.

HorstBaerbel commented 2 years ago

Those warnings are unrelated. I have a solution I'm working on right now.

Cool. Let me if you need help beta-testing etc.

endrift commented 2 years ago

The branch is at https://github.com/endrift/mgba/tree/fix/wayland. If you're on GNOME, I'd love it tested. On KDE, for some reason, the menu disappears when you start a game. It also breaks macOS, so I need to work on that still.

HorstBaerbel commented 2 years ago

Yes, I'm on GNOME. Built with: cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_CONFIG=Release -DUSE_LZMA=OFF -DUSE_MINIZIP=OFF .. Output:

-- The C compiler identification is GNU 12.1.1
-- The CXX compiler identification is GNU 12.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
-- Looking for strdup
-- Looking for strdup - found
-- Looking for strlcpy
-- Looking for strlcpy - not found
-- Looking for strndup
-- Looking for strndup - found
-- Looking for vasprintf
-- Looking for vasprintf - found
-- Looking for freelocale
-- Looking for freelocale - found
-- Looking for newlocale
-- Looking for newlocale - found
-- Looking for setlocale
-- Looking for setlocale - found
-- Looking for snprintf_l
-- Looking for snprintf_l - not found
-- Looking for uselocale
-- Looking for uselocale - found
-- Looking for popcount32
-- Looking for popcount32 - not found
-- Looking for futimens
-- Looking for futimens - found
-- Looking for futimes
-- Looking for futimes - found
-- Looking for localtime_r
-- Looking for localtime_r - found
-- Looking for include file xlocale.h
-- Looking for include file xlocale.h - not found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Performing Test HAVE_PTHREAD
-- Performing Test HAVE_PTHREAD - Success
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Looking for include file pthread_np.h
-- Looking for include file pthread_np.h - not found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - found
-- Looking for pthread_set_name_np
-- Looking for pthread_set_name_np - not found
-- Checking for one of the modules 'libedit'
-- Checking for one of the modules 'libavcodec'
-- Checking for one of the modules 'libavfilter'
-- Checking for one of the modules 'libavformat'
-- Checking for one of the modules 'libavutil'
-- Checking for one of the modules 'libswscale'
-- Checking for one of the modules 'libswresample'
-- Checking for one of the modules 'libzip'
CMake Warning at src/platform/cmake/FindFeature.cmake:91 (message):
  Requested module libzip missing for feature USE_LIBZIP.  Feature disabled.
Call Stack (most recent call first):
  CMakeLists.txt:484 (find_feature)

-- Checking for one of the modules 'epoxy'
CMake Warning at src/platform/cmake/FindFeature.cmake:91 (message):
  Requested module epoxy missing for feature USE_EPOXY.  Feature disabled.
Call Stack (most recent call first):
  CMakeLists.txt:485 (find_feature)

-- Checking for one of the modules 'SQLite3'
-- Checking for one of the modules 'sqlite3'
CMake Warning at src/platform/cmake/FindFeature.cmake:91 (message):
  Requested module SQLite3|sqlite3 missing for feature USE_SQLITE3.  Feature
  disabled.
Call Stack (most recent call first):
  CMakeLists.txt:487 (find_feature)

-- Checking for one of the modules 'libelf'
-- Checking for one of the modules 'Lua'
CMake Warning at src/platform/cmake/FindFeature.cmake:91 (message):
  Requested module Lua missing for feature USE_LUA.  Feature disabled.
Call Stack (most recent call first):
  CMakeLists.txt:743 (find_feature)

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found SDL2: /usr/lib64/libSDL2.so  
-- Build type: Release
-- Platforms:
--  Game Boy Advance: ON
--  Game Boy: ON
-- Features:
--  Debuggers: ON
--  CLI debugger: ON
--  GDB stub: ON
--  GIF/Video recording: ON
--  Screenshot/advanced savestate support: ON
--  ZIP support: minizip (included)
--  7-Zip support: OFF
--  SQLite3 game database: ON
--  ELF loading support: ON
--  Discord Rich Presence support: ON
--  OpenGL support: OpenGL, OpenGL|ES 2, OpenGL|ES 3
-- Scripting support: ON
--  Lua: OFF
-- Frontends:
--  Qt: ON
--  SDL (2): ON
--  Python bindings: OFF
--  Examples: OFF
-- Test tools:
--  Profiling: OFF
--  Test harness: OFF
--  Test suite: OFF
--  Video test suite: OFF
--  ROM tester: OFF
-- Cores:
--  Libretro core: OFF
-- Libraries:
--  Static: OFF
--  Shared: ON
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:
    CMAKE_CONFIG

Compiled, ran. Switched to Display driver "OpenGL". Mouse vanished when hovering over mGBA. Restarted, could load a ROM, music plays, but display does not update. When I hover menu bar items I get "qt.qpa.wayland: Wayland does not support QWindow::requestActivate()" in the console. When I try to load new ROM the display gets updated with a single frame from the emulation.

endrift commented 1 year ago

@HorstBaerbel I've updated the branch. Please try again.

HorstBaerbel commented 1 year ago

Nice. Works fire with OpenGL! I get two

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

but else than that it is working fine.

HorstBaerbel commented 1 year ago

Ah, no wait. I had switched to X11... Need to retest...

HorstBaerbel commented 1 year ago

Nope, same problem as before with Gnome / Wayland.

endrift commented 1 year ago

Dang. That fixed it on KDE/Plasma for me, but it works on GNOME for some reason. What version of mutter is installed?

HorstBaerbel commented 1 year ago

What version of mutter is installed?

mutter.x86_64 42.2-1.fc36

endrift commented 1 year ago

Hm, are you sure you updated? Running that branch on a fresh Fedora 36 live image on an Intel GPU works, but going back to master doesn't. Can you confirm what commit you're on?

HorstBaerbel commented 1 year ago

On commit "65280a9665e5f24694a060ac6627a5b0748cd845 (HEAD -> fix/wayland)". It's better than before. Sometimes ROMs load and run, sometimes they don't. It's hit-and-miss. I'm running Qt 5.15.3 and and Nvidia GPU with the 510 proprietary driver, so it might also be a driver problem. Will retest with newer driver.

atsen-dev commented 1 year ago

Any update on this issue ?

endrift commented 1 year ago

It was closed because it was fixed. There hasn't been a release since however.

atsen-dev commented 1 year ago

OKay, did you know when we'll have a new release ? Thanks

endrift commented 1 year ago

Early August hopefully. In the meantime you can use a development build or compile from source.