kleinerm / Psychtoolbox-3

This is kleinerm's git repository for development of Psychtoolbox-3. Regular end users should stay away from it, unless instructed by him otherwise, and use the official Psychtoolbox-3 GitHub page or distribution system for production releases.
104 stars 304 forks source link

Ubuntu 20.10 and libdc1394.so.25 #187

Closed iandol closed 3 years ago

iandol commented 3 years ago

For the newly released Ubuntu 20.10, libdc1394 has been updated to libdc1394.so.25 and cannot be found on PTB startup.

MATLAB:mex:ErrInvalidMEXFile
Invalid MEX-file
'/home/cog5/Code/Psychtoolbox-3/Psychtoolbox/PsychBasic/Screen.mexa64':
libdc1394.so.22: cannot open shared object file: No such file or directory 

If I manually add a softlink sudo ln -s libdc1394.so.25 libdc1394.so.22 then PTB works fine. GStreamer has also been updated to 1.18 for 20.10 and seems to work fine.

kleinerm commented 3 years ago

Thanks for reporting this. I wasn't able to test 20.10 at all yet - a first in over a decade that i'm not ahead of releases but behind :(.

That's annoying. Can you check for me in the package manager if by any chance there's an optional install of libdc1394.so.22 available? Solving this properly would probably require shipping dedicated Screen mex files just for 20.10+, or dynamic runtime linking, and i'm 1 day away from the next big PTB release.

Does sound output work, e.g., BasicSoundOutputDemo ?

iandol commented 3 years ago

I doubt many people will update; I did because on my dev machine I have a high-DPI monitor that Gnome has all sorts of problems with and I was hoping the new Gnome improved high-DPI support (it didn't). As an aside, the updated MESA seems significantly faster, ProceduralGarboriumDemo now goes up to 7300 before starting to drop frames (though I do have to add a Priority command to do so), looking at the code I actually realise that number is per type, so it actually means 7300 gabors + 7300 blobs, 14600 procedural shaders in total!

For libdc1394 I can only see a "transitional" dev package, I can give that a go?

[I] ➜ apt search libdc1394
Sorting... Done
Full Text Search... Done
libdc1394-22-dev/groovy 2.2.6-3 amd64
  transitional package

libdc1394-22-doc/groovy,groovy 2.2.6-3 all
  transitional package

libdc1394-25/groovy,now 2.2.6-3 amd64 [installed,automatic]
  high level programming interface for IEEE 1394 digital cameras

libdc1394-dev/groovy 2.2.6-3 amd64
  high level programming interface for IEEE 1394 digital cameras - development

libdc1394-doc/groovy,groovy 2.2.6-3 all
  high level programming interface for IEEE 1394 digital cameras - documentation

libdc1394-utils/groovy,now 2.2.6-3 amd64 [installed]
  utilities for IEEE 1394 digital cameras

And yes, BasicSoundOutputDemo appears broken...

>> BasicSoundOutputDemo
PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: ALC3234 Analog (hw:0,0)] as default output audio device.
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Unanticipated host error 
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
Error in function Open:     Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.

Could not open device at wanted playback frequency of 48000 Hz. Will retry with device default frequency.
Sound may sound a bit out of tune, ...

PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: ALC3234 Analog (hw:0,0)] as default output audio device.
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Unanticipated host error 
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
Error in function Open:     Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Error using PsychPortAudio
Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][,
suggestedLatency][, selectchannels][, specialFlags=0]);

Error in BasicSoundOutputDemo (line 88)
    pahandle = PsychPortAudio('Open', device, [], 0, [], nrchannels);
iandol commented 3 years ago

OK, installing the transitional package only installs the dev package which adds an unversioned /usr/lib/x86_64-linux-gnu/libdc1394.so, deleting my custom symlink and restarting PTB and I get the same linking error...

kleinerm commented 3 years ago

Ok. I guess then there isn't any clean and simple low effort solution. Maybe i'll have to add code to create the symlink to PsychLinuxConfiguration. The Octave mex files for 20.10 are built on 20.04 and that already has the dev package for libdc1394.so.25, so i can make this work for Octave. But building a totally separate Matlab mex file just for 20.10 seems excessive, so i'll probably go with the symlink, as dirty as that is.

The sound failure is bad. I observed that with my Linux 5.8-rc development kernel, but hoped it would be a fluke specific to my machine and get fixed by upstream in time. Seems it made it into the official 5.8 kernel that is used by Ubuntu 20.10.

It's frustrating that i could not keep up with testing.

Wrt. mixed low dpi and HiDPI monitor setups, i think Gnome or KDE handle them well if the Wayland display server is used, instead of the standard X-Server. I think KDE does an even better job than macOS with that. Unfortunately Wayland and PTB won't work well together at all yet, at least not for production work where timing and control matter. Wayland has ways to go before it is ready for demanding low-level tasks like the one PTB needs.

iandol commented 3 years ago

Yes, i wish we could finally switch over to Wayland, it seems there is at least ongoing development, much more than for x-server at least. I had hoped I could get hi-DPI monitors and use them for daily use, but there are still lots of glitches at least for Gnome (auto-hiding the dock fails, a rogue mouse pointer remains drawn on the screen, blurry text in some places, MATLAB's document browser fails to scale etc.).

I could test a 2.9 development kernel to see if it solves the audio issue?

kleinerm commented 3 years ago

Yes, i wish we could finally switch over to Wayland, it seems there is at least ongoing development, much more than for x-server at least. I had hoped I could get hi-DPI monitors and use them for daily use, but there are still lots of glitches at least for Gnome (auto-hiding the dock fails, a rogue mouse pointer remains drawn on the screen, blurry text in some places, MATLAB's document browser fails to scale etc.).

I think for regular desktop use it is slowly getting there. For neuroscience use otoh., despite myself being occassionally involved in some Wayland development, i wouldn't want to make a prediction if we are a year, years, 5 years or a decade away from something suitable that matches or exceeds the X-Server in common use cases... You also have the chicken and egg problem that development of native Wayland apps waits for Wayland to mature, Most X-Apps will never get ported, so are always legacy running in an emulated X-Server (XWayland). And then there's apps built on modern GUI toolkits like Qt where the toolkit makes them run as X-Apps on an X-Server and Wayland apps on Wayland, but now it depends on how well those toolkits keep up in doing a good middleman role... And the fact that there are x different Wayland server implementations out there also doesn't help. It's probably that the more niche and specialized a Wayland server is, the more likely it will implement the specialized "fringe" features quickly that PTB needs, whereas the more popular, the bigger the inertia in dealing with special interest groups. I assume from personal experience that Gnome would be the one with the biggest inertia...

The X-Server has a bit of a limbo problem. Development of the server is still moving forward, but what is developed doesn't get released, because atm. nobody wants to do the work intense and thankless job of being the release manager, given that Wayland is always "just around the corner...". Still, for special use cases like neuroscience, X at age 35+ years is still far ahead of anything else for almost all use cases, and especially compared to Windows or macOS.

I could test a 2.9 development kernel to see if it solves the audio issue?

That would be a time saver for me, thanks. You know of the Ubuntu mainline ppa where you can get easy to install builds of the latest stable and development kernels?

iandol commented 3 years ago

Yes, I installed 5.9.1 from https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.9.1/

[I] ➜ uname -a                    
Linux cog5 5.9.1-050901-generic #202010170731 SMP Sat Oct 17 07:42:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

BUT BasicSoundOutputDemo still fails with the same error...

kleinerm commented 3 years ago

Ok, so the bug happens somewhere between Linux 5.4 and 5.8. Could you try Linux 5.6 and then depending on success or failure either 5.7 (if 5.6 worked) or 5.5 (if 5.6 failed as well)?

iandol commented 3 years ago

Used this to automate the search and downloading a bit: https://github.com/pimlie/ubuntu-mainline-kernel.sh

5.5.19 works, 5.6.0 + 5.6.19 (first and last builds for 5.6.x) fail...

kleinerm commented 3 years ago

Neat script. Your results match mine. Bug was introduced sometime for Linux 5.6. Now comes the tedious part, figuring out what the bug is... Thanks.

kleinerm commented 3 years ago

Ok, so it wasn't a Linux 4.6 bug, but a > 13 years old libportaudio bug which was triggered the first time by improvements made to Linux 4.6. See commit 0f892305c976eb29c18f7556f36e11dac057305a for explanation and current workaround "fix". I guess the upstream fix will take quite a while until it lands in a Linux distro. But this should do for all practical purposes for us, although not fixing it for other apps yet.

Thanks for the help.

iandol commented 3 years ago

Can confirm it is now working on my 20.10 machine running a 5.8 kernel. Thanks Mario!