jankammerath / iptvx

IPTV player and streamer for Linux that allows to play any stream that LibVLC can play, offers an overlay based on WebKit using HTML5, JavaScript and CSS and uses XMLTV data for EPG information. It allows the playback of URLs, files and can grab URLs from shell scripts. XMLTV EPG data can be downloaded from URLs or grabbed from shell scripts.
http://iptvx.org
Apache License 2.0
80 stars 37 forks source link

Optimise rendering performance #68

Closed jankammerath closed 6 years ago

jankammerath commented 6 years ago

There are minor glitches in rendering performance even with hardware support. These are hard to realise, but if one looks closely at the video there is evidence that certain frames are dropped.

jankammerath commented 6 years ago

Use gprof for analysis.

jankammerath commented 6 years ago

Here are some good tips for SDL: http://forums.libsdl.org/viewtopic.php?p=30505

jankammerath commented 6 years ago

The root of all evil is in the overlay rendering of the PNG into the SDL window. Rethinking the whole rendering style or design is probably necessary.

jankammerath commented 6 years ago

Some fixes are done now, but the _cairo_surfacet should be written directly onto the _SDLSurface without the use of PNG rendering. That could give slightly more performance.

jankammerath commented 6 years ago

from https://cairographics.org/manual/cairo-cairo-surface-t.html, example 1, get data/width/height/stride of your cairo surface, and create your SDL_Surface or SDL_Texture with those information, for instance, with SDL_CreateRGBSurfaceWithFormatFrom() or SDL_UpdateTexture()."

Source: https://discourse.libsdl.org/t/webkit-surface-on-sdl-using-cairo-directly-instead-of-png/23688/2

jankammerath commented 6 years ago

Switch rendering to directfb: http://sdl.beuc.net/sdl.wiki/SDL_envvars

vlelin commented 6 years ago

hardware acceleration?

jankammerath commented 6 years ago

@vlelin hardware acceleration?

HW acceleration to a certain extent is in the master branch and switched on by default. It can be configured using the render configuration setting. The major issue with performance at the moment is that the transfer of the PNG data from the overlay to the SDL rendering can create minor, almost not noticable, but present glitches. Furthermore the rendring engine (e.g. DirectFB) should be configurable.

jankammerath commented 6 years ago

Latest commit hard forces "directfb" when render is set to "hw"

jankammerath commented 6 years ago

I am closing this issue now as latest commit has reduced CPU utilisation from 58-64% to now about 24%-35% on my development machine with debug-compile. The PNG data is now only written when WebKit sends a "draw" signal (connected by g_signal_connect). Furthermore in the drawing loop for SDL the PNG is only read when it's timestamp is updated (in milliseconds) to prevent too much PNG reading. The cairo_surface_t conversion to SDL_Surface will not provide much for gain, so that is ignored.

With all these changes, all required performance improvements from this issue are not fixed.