Latest Tweets

After upgrading to Ubuntu 14.04 LTS, okular crashes whilst playing AVIS inside a PDF file.

The issue

Before upgrading to Ubuntu 14.04 LTS, Okular was able to play AVIS inside a pdf file without problems. After the upgrade, Okular was crashing randomly during AVI reproduction.  Some crashes happened as soon as the first AVI video was played, whereas others were triggered after an unknown number of videos being successfully played. Either way, okular crashed showing this exact error on the console:

Okular crash reporting error

Okular crash reporting error

A reported BUG

Before wasting time in a hard and difficult debugging session with GDB, I resolved to look for this apparent BUG on the website. It turned out there was a reported BUG right here: However, according to this post, the BUG was located in the libkscreen library’s code, a library Okular was making use of. I tried first the “workaround” solution presented on the post, with no success at all. So, in order to make sure the BUG was really in that library, I got the Okular sources for the Ubuntu 14.04 LTS with the apt-get tool and removed the libkscreen library from the compilation process:

# apt-get source okular

# apt-get build-dep okular

Removing libkscreen references from the compilation process involved editing the cmake file CMakeLists.txt and commenting out a couple of lines:

Removing the libkscreen library from okular's compilation process.

Removing the libkscreen library from okular’s compilation process.

To prevent the compilation process from failing, I had to comment out another line of code in the config-okular.h header file:

Removing the HAVE_KSCREEN directive from the okular source code.

Removing the HAVE_KSCREEN directive from the okular source code.

Before starting the compilation process, I ran the cmake utility to create the makefiles and I made sure there was no reference to the kscreen external library:

The libkscreen has not been added to the Okular project.

Libkscreen has been removed from the Okular project.

After doing this, I compiled the entire Okular project by running:

      -DCMAKE_BUILD_TYPE=Release         \
      -Wno-dev .. &&

The compilation process ended and I ran the new  Okular binary, getting the same error as before. Crap!

A second reported BUG

Okay; the first approach had proven to be a complete failure. I decided to search for a bit longer on the website, in search of a more plausible solution to the problem at hand. Soon enough I came to this To be honest, this one was more like what I was looking for. Yet, it had to be checked. As far as this post was concerned, the real issue was located in the phonon-backend-gstreamer library. It made sense, so I decided to give it a try. I got the source code for the phonon-backend-gstreamer Ubuntu 14.04 LTS package and made all the source changes according to the website; then I compiled the new library and put it in the same place as the original one, overwriting it:

# apt-get source phonon-backend-gstreamer

# apt-get build-dep phonon-backend-gstreamer

… some editing …


# cp gstreamer/ /usr/lib/x86_64-linux-gnu/qt4/plugins/phonon_backend/

I ran the original Okular binary and this time it did not crash. However, its behaviour was a bit odd: the videos did not show up until I clicked on them, and the first time they did not render correctly. Well, it was obvious that the BUG was effectively in the phonon-backend-gstreamer library and not in the libkscreen one. Although this patch was indeed an improvement – Okular was not crashing at all -, it was far from being a good solution so I decided to use GDB and try to understand what was happening behind the scenes.

In doing so I discovered that I could choose whatever backend I would like to use in order to play videos and sound in the KDE desktop. Looking around with the apt-cache tool I found more backends than just the gstreamer one:

A list of available phonon backends to render audio and video.

A list of available phonon backends to render audio and video.

So my reasoning went: If the BUG is a regression one inside the phonon-backend-gstreamer library, why don’t use another backend? Thus, I removed the phonon-backend-gstreamer package and installed the phonon-backend-vlc one instead. After that, I ran the Okular and not only it did not crash at all, but it was rendering the videos perfectly well too!. To sum up, the problem could be easily fixed this way:

# apt-get remove phonon-backend-gstreamer

# apt-get install phonon-backend-vlc

# apt-get install okular

So far so good. Sometimes fixing something is easier than originally expected. Cheers!