sr99622 / libonvif

Onvif library with GUI implementation and built in YOLOX
GNU Lesser General Public License v2.1
175 stars 45 forks source link

Window rendering transparent and leaving artifacts #65

Open leechpool-github opened 1 year ago

leechpool-github commented 1 year ago

I installed this on Ubuntu 22.04. It initially worked brilliantly. But after reboot, whenever I run it, it works ok, can display cameras etc, BUT the window rendering has for some reason broken. The grey screen where the camera image would be is transparent when it first starts. If I go to view a camera it appears BUT if I move the window or resize it the borders etc leave artefacts within the app window as the geometry is moved across the screen. Difficult to describe but I hope it makes sense. I loved this program when it was working and was really looking forward to using it, but since the first install I just can't get the rendering to work. I've tried removing and reinstalling. Rebooting several times and even installing from source with your instructions; all to no avail. You can tell by now I'm not a linux wizard but I wonder if it is something to do with my graphics settings, however, no other programs / windows show this behaviour. If you could assist it getting it working I would be extremely grateful. I just went to take a screenshot of it to see if I could upload to assist. Oddly the screenshot doesn't show the artefacts etc, just the chequered effect you get to show transparency in some apps.... :)

leechpool-github commented 1 year ago

GUI

This is what I'm seeing (before discovering cameras, taken with my phone camera).

sr99622 commented 1 year ago

This effect is usually caused by the default Noeveau graphics drivers that come pre-installed on Ubuntu. To get correct operation, the proprietary NVDIA drivers should be installed.

There are many tutorials of varying quality on the internet on how to do this, but the most basic method is to:

Open the Software & Updates application window. Select TAB Additional Drivers and choose any proprietary NVIDIA driver. The higher the driver number the latest the version.

This is taken from the page https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-22-04, using the first method, GNOME GUI Nvidia Installation Method

Hope this clears up the issue, thank you so much for reaching out.

leechpool-github commented 1 year ago

Thanks so much for coming back so quickly. I really appreciate it. I don't have an NVIDIA card. I have a AMD Radeon RX580.

Output from inxi -G as follows......... Graphics: Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] driver: amdgpu v: kernel Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: amdgpu,ati unloaded: fbdev,modesetting,radeon,vesa gpu: amdgpu resolution: 3840x2160~60Hz OpenGL: renderer: AMD Radeon RX 570 Series (polaris10 LLVM 15.0.7 DRM 3.47 5.19.0-46-generic) v: 4.6 Mesa 22.2.5-0ubuntu0.1~22.04.3

Thanks for pointing me in the graphics driver direction. I guess I didn't consider that because I've never seen this rendering effect before. I'll do some investigating / experimenting.

Any further advice you have would be very welcome.

sr99622 commented 1 year ago

Sorry for your troubles. The root of the problem most likely will be somewhere in the OpenGL processing done by the GPU card, as this is how Qt renders the graphics in this case. Unfortunately, I don't have any experience with AMD cards. I did some research and it seems like they recently updated the OpenGL functions to fix some known issues. It seems like normally, the default drivers built into the kernel should work properly, but there may be a chance that ubuntu 22.04 has the older drivers and an upgrade to the new AMD drivers will resolve the problem.

On the other hand, it is possible that the Qt OpenGL functions have some issues and this approach may not work as expected, it's hard to know without an actual card to test.

leechpool-github commented 1 year ago

Hi, it's no trouble at all. I've been looking for a simple program that can display and PTZ onvif cameras without the overhead of trying to decode all connected cameras at once so that my wife can view our cameras and move/zoom them etc if she sees something she is interested in.... So, I tried installing on an old laptop without AMD graphics: Graphics: Device-1: Intel Haswell-ULT Integrated Graphics driver: i915 v: kernel Device-2: Realtek USB Webcam type: USB driver: uvcvideo Display: wayland server: X.Org v: 1.22.1.1 with: Xwayland v: 22.1.1 compositor: gnome-shell v: 42.9 driver: X: loaded: modesetting unloaded: fbdev,vesa gpu: i915 resolution: 1920x1080~60Hz OpenGL: renderer: Mesa Intel HD Graphics 4400 (HSW GT2) v: 4.6 Mesa 22.2.5-0ubuntu0.1~22.04.3

Curiously, I got the same rendering issue!? Incidentally, I've found I can't get it to work on Ubuntu 18.04 or 20.04. Only 22.04 seems to work (very easy install). I just keep getting this window issue. It's kind of usable because if you adjust height and width to get the stream pane to be exactly right, it then looks ok and if you switch to a different camera, it then puts black borders top or bottom / side if the stream resolution is different. It's just not as convenient as if the rendering worked as it's intended :). Happy to try things if you have an appetite and time to try to debug and can put up with my level of competence LOL. Really useful program though even with this issue. Cheers

leechpool-github commented 1 year ago

Hi, I don't know whether this helps to narrow down what is going on, but I've found that sometimes I can boot Ubuntu and it works perfectly. When this happens I note that the app remembers the last position it was on on the screen. i.e. if I shut it down and restart it it goes back to the same position and size on screen. If it is working, it will stay working through shut app, reopen app etc as many times as you like. Then when you reboot or shutdown and restart, sometimes (most times) it is broken again. When it is broken it has always forgotten its size and position on screen and always starts relatively small and in the centre. When it is broken, it will remain broken through close / reopen app until I restart / shutdown the PC. Cheers Roger

sr99622 commented 1 year ago

Hi Roger,

I was able to reproduce the effects you have observed on an old laptop without a GPU. I was unaware of the issue as all of my computers that I normally work on have NVIDIA gpu and once the drivers are installed, there were not any issues, so I concluded that the gpu driver was the necessary ingredient.

I have also noticed that it was necessary to install the optional proprietary drivers during ubuntu installation to get proper operation, at least with this test machine I'm working on now.

Thank you so much for your help. Without your messages, I would still be in the dark regarding this issue. I will work on getting this fixed, but there are some unknown variables in the mix, so it's hard to know how long it might take to track down.

Best Regards,

Stephen

leechpool-github commented 1 year ago

Hi, Again, thanks so much for this application and your willingness to try to help people with issues. It's a great app! I really appreciate you taking time to replicate the issue and considering trying to fix it. I have been thrashing about at my end trying to investigate as well with my limited knowledge and I've made significant progress! :)

I have found that the issue with Ubuntu goes away if you stop using Wayland and use X11 instead (I really don't understand all of this but I googled so much and just tried lots of things...).

To change Ubuntu back to using X11 (Wayland is a relatively recent thing apparently), you go into /etc/gdm3/custom.conf and un hash the line which says #WaylandEnable=false

So, to edit you might use: sudo gedit /etc/gdm3/custom.conf You need to reboot. You can check you are using X11 with: echo $XDG_SESSION_TYPE

I know the above works because I now have tried in on two machines running Ubuntu 22.04 and two different laptops running ubuntu 22.04, all with various graphics cards.

Hopefully, this should help any Ubuntu users who experience the issue. I believe Wayland is becoming the norm so if you could make the app play nicely with Wayland that would be great, assuming the issue isn't effectively a bug in Wayland....

Huge thanks! Roger

sr99622 commented 1 year ago

Wow that is some impressive work. The whole field of study seems pretty murky but you've definitely found a proper solution. Following your lead, I was able to uncover the Qt settings for operation under wayland. If you set an environment variable QT_QPA_PLATFORM=xcb this will bring correct behavior to the Qt app. This way it is not necessary to disable the wayland settings which seems like a good thing in case somebody is using those for something.

I will need to do some more testing and such to smooth out the wrinkles of setting the environment variable, but it looks like we have a fix in place. Thank you so much for following up with this, you've been a tremendous help.

Best Regards,

Stephen

leechpool-github commented 1 year ago

Superb. Well done. I wish I understood more of this! LOL I added "export QT_QPA_PLATFORM=xcb" command to the launcher I set up for onvif-gui and rehashed the WaylandEnable=false in /etc/gdm3/custom.conf i.e. re-enabled Wayland. I then rebooted and checked I was running Wayland. The launcher worked perfectly with the environment variable set as you instructed. The window rendered as it should. I then checked this also worked on one of the laptops and again it worked perfectly. Very happy. Can't thank you enough for this great program and all your support. Cheers Roger