sailfishos-flatpak / main

Documentation and issues
MIT License
25 stars 4 forks source link

Hybris linker not used on aarch64/AOSP10 based port #21

Open rinigus opened 3 years ago

rinigus commented 3 years ago

For example, Angelfish not HW accelerated on aarch64/AOSP10 based port. On the basis of chrome://gpu, there is no hardware acceleration. Tested on Sony Tama

rinigus commented 3 years ago

Looks like hybris is not used. When forcing its use via

flatpak-runner --env=LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/GL/host/lib64 \
 --filesystem=host org.kde.mobile.angelfish

application will exit with error. Looking through strace, we have no loading of hybris linker:

openat(AT_FDCWD, "/usr/lib/aarch64-linux-gnu/GL/host/lib64/libwayland-egl.so.1", O_RDONLY|O_CLOEXEC) = 9
read(9, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0P\6\0\0\0\0\0\0"..., 832) = 832
fstat(9, {st_mode=S_IFREG|0755, st_size=67464, ...}) = 0
mmap(NULL, 131120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0) = 0x773fdfe000
mprotect(0x773fdff000, 122880, PROT_NONE) = 0
mmap(0x773fe1d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0xf000) = 0x773fe1d000
close(9)                                = 0
openat(AT_FDCWD, "/usr/lib/aarch64-linux-gnu/GL/host/lib64/libhardware.so.2", O_RDONLY|O_CLOEXEC) = 9
read(9, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\20\6\0\0\0\0\0\0"..., 832) = 832
fstat(9, {st_mode=S_IFREG|0755, st_size=67520, ...}) = 0
mmap(NULL, 131144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0) = 0x773fddd000
mprotect(0x773fdde000, 122880, PROT_NONE) = 0
mmap(0x773fdfc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0xf000) = 0x773fdfc000
close(9)                                = 0
mprotect(0x773fdfc000, 4096, PROT_READ) = 0
mprotect(0x773fe1d000, 4096, PROT_READ) = 0
mprotect(0x773fe3e000, 4096, PROT_READ) = 0
mprotect(0x773fe5e000, 4096, PROT_READ) = 0
fstat(2, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(2, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(2, "/app/bin/angelfish: symbol looku"..., 163/app/bin/angelfish: symbol lookup error: /usr/lib/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so: undefined symbol: eglGetPlatformDisplay
) = 163
exit_group(127)                         = ?
+++ exited with 127 +++
[D] expression for onExit:59 - Skipping quit as it will hang the window. Proper exit is needed
rinigus commented 3 years ago

From strace, looks like linker is not engaged at all as it is not looked for nor loaded

rinigus commented 3 years ago

strace with full arguments

flatpak-runner --devel --env=LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/GL/host/lib64 --filesystem=host  \
  --command=strace org.kde.mobile.angelfish -v -s 1024 /app/bin/angelfish

...

openat(AT_FDCWD, "/usr/lib/aarch64-linux-gnu/GL/host/lib64/libwayland-egl.so.1", O_RDONLY|O_CLOEXEC) = 9
read(9, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0P\6\0\0\0\0\0\0@\0\0\0\0\0\0\0H\1\1\0\0\0\0\0\0\0\0\0@\08\0\7\0@\0\31\0\30\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\t\0\0\0\0\0\0@\t\0\0\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\6\0\0\0\320\375\0\0\0\0\0\0\320\375\1\0\0\0\0\0\320\375\1\0\0\0\0\0X\2\0\0\0\0\0\0`\2\0\0\0\0\0\0\0\0\1\0\0\0\0\0\2\0\0\0\6\0\0\0\340\375\0\0\0\0\0\0\340\375\1\0\0\0\0\0\340\375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\0\0\0\0\0\0\0\0\0\177\0\0\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\234\0\0\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,\0\0\0 \0\0\0\0\0\0\0\0\0\0\0", 832) = 832
fstat(9, {st_dev=makedev(0xfc, 0x1), st_ino=469403, st_mode=S_IFREG|0755, st_nlink=1, st_uid=100000, st_gid=100000, st_blksize=4096, st_blocks=136, st_size=67464, st_atime=1620316253 /* 2021-05-06T15:50:53.415958475+0000 */, st_atime_nsec=415958475, st_mtime=1610937285 /* 2021-01-18T02:34:45+0000 */, st_mtime_nsec=0, st_ctime=1620316253 /* 2021-05-06T15:50:53.415958475+0000 */, st_ctime_nsec=415958475}) = 0
mmap(NULL, 131120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0) = 0x793cf93000
mprotect(0x793cf94000, 122880, PROT_NONE) = 0
mmap(0x793cfb2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0xf000) = 0x793cfb2000
close(9)                                = 0
openat(AT_FDCWD, "/usr/lib/aarch64-linux-gnu/GL/host/lib64/libhardware.so.2", O_RDONLY|O_CLOEXEC) = 9
read(9, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\20\6\0\0\0\0\0\0@\0\0\0\0\0\0\0@\1\1\0\0\0\0\0\0\0\0\0@\08\0\7\0@\0\32\0\31\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\354\t\0\0\0\0\0\0\354\t\0\0\0\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\6\0\0\0\220\375\0\0\0\0\0\0\220\375\1\0\0\0\0\0\220\375\1\0\0\0\0\0\230\2\0\0\0\0\0\0\270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0\0\0\0\0\0F\0\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0r\0\0\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0U\0\0\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0d\0\0\0\22\0\f\0\10\7\0\0\0\0\0\0", 832) = 832
fstat(9, {st_dev=makedev(0xfc, 0x1), st_ino=469389, st_mode=S_IFREG|0755, st_nlink=1, st_uid=100000, st_gid=100000, st_blksize=4096, st_blocks=136, st_size=67520, st_atime=1620316253 /* 2021-05-06T15:50:53.248958475+0000 */, st_atime_nsec=248958475, st_mtime=1619957353 /* 2021-05-02T12:09:13+0000 */, st_mtime_nsec=0, st_ctime=1620316253 /* 2021-05-06T15:50:53.248958475+0000 */, st_ctime_nsec=248958475}) = 0
mmap(NULL, 131144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0) = 0x793cf72000
mprotect(0x793cf73000, 122880, PROT_NONE) = 0
mmap(0x793cf91000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0xf000) = 0x793cf91000
close(9)                                = 0
mprotect(0x793cf91000, 4096, PROT_READ) = 0
mprotect(0x793cfb2000, 4096, PROT_READ) = 0
mprotect(0x793cfd3000, 4096, PROT_READ) = 0
mprotect(0x793cff3000, 4096, PROT_READ) = 0
fstat(2, {st_dev=makedev(0, 0xb), st_ino=234025, st_mode=S_IFIFO|0600, st_nlink=1, st_uid=100000, st_gid=100000, st_blksize=4096, st_blocks=0, st_size=0, st_atime=1620469773 /* 2021-05-08T10:29:33.019251473+0000 */, st_atime_nsec=19251473, st_mtime=1620469773 /* 2021-05-08T10:29:33.023254852+0000 */, st_mtime_nsec=23254852, st_ctime=1620469773 /* 2021-05-08T10:29:33.023254852+0000 */, st_ctime_nsec=23254852}) = 0
lseek(2, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(2, "/app/bin/angelfish: symbol lookup error: /usr/lib/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so: undefined symbol: eglGetPlatformDisplay\n", 163/app/bin/angelfish: symbol lookup error: /usr/lib/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so: undefined symbol: eglGetPlatformDisplay
) = 163
exit_group(127)                         = ?
rinigus commented 3 years ago

issue was in the absence of eglGetPlatformDisplay in libhybris. So, to get it loaded, it has to be defined. Mal and Thaodan suggested to test https://github.com/libhybris/libhybris/pull/469 . It required addition of https://github.com/libhybris/libhybris/commit/2d40517ca87786a1b979d83c6fa1123220d468f1 (hybris/egl/egl.c part), except eglGetPlatformDisplay.

While hybris does load, application is not showing anything in flatpak-runner. It also crashes with

Thread 1 "angelfish" received signal SIGBUS, Bus error.
0x0000000000000003 in ?? ()

Thread 2 (Thread 0x7fb33d8f20 (LWP 8)):
#0  0x0000007fb85a9cd4 in poll () from /usr/lib/aarch64-linux-gnu/libc.so.6
#1  0x0000007fb46fd46c in g_main_context_iterate.constprop () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x0000007fb46fd594 in g_main_context_iteration () from /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#3  0x0000007fb8a9f618 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
#4  0x0000007fb8a5fcd0 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
#5  0x0000007fb891cf24 in QThread::exec() () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
#6  0x0000007fb8478e24 in ?? () from /usr/lib/aarch64-linux-gnu/libQt5DBus.so.5
#7  0x0000007fb891e180 in ?? () from /usr/lib/aarch64-linux-gnu/libQt5Core.so.5
#8  0x0000007fbfc4f648 in start_thread () from /usr/lib/aarch64-linux-gnu/libpthread.so.0
#9  0x0000007fb85b39dc in thread_start () from /usr/lib/aarch64-linux-gnu/libc.so.6

Thread 1 (Thread 0x7fb38b7020 (LWP 5)):
#0  0x0000000000000003 in ?? ()
#1  0x0000007fb21a0e68 in ?? ()
#2  0x000000555594ca50 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
A debugging session is active.

        Inferior 1 [process 5] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]

with Maliit extension installed. Without extension, it will just hang not showing anything.

rinigus commented 2 years ago

Padding didn't make any difference. As Flatpak works for Droidian/AOSP10/aarch64, it could be that their hybris is in a better shape for it. See https://github.com/droidian/libhybris and defined eglGetPlatformDisplay

rinigus commented 2 years ago

If libhybris will get updated in SFOS 4.3, use that for testing. Looks like there are changes in eglGetPlatformDisplay in the latest libhybris