jim-easterbrook / Photini

An easy to use digital photograph metadata (Exif, IPTC, XMP) editing application.
https://photini.readthedocs.io/
GNU General Public License v3.0
163 stars 24 forks source link

Crash on exit after GLib errors being wrongly reported #40

Closed jim-easterbrook closed 5 years ago

jim-easterbrook commented 5 years ago

I've found a nasty interaction between QtWebEngineWidgets and GExiv2, both of which are essential to Photini (if you want any map tabs). Here's my test script:

import gi
gi.require_version('GExiv2', '0.10')
from gi.repository import GExiv2

from PyQt5 import QtWidgets, QtWebEngineWidgets

def main():
    app = QtWidgets.QApplication([])
##    page = QtWebEngineWidgets.QWebEnginePage()
    md = GExiv2.Metadata()
    md.open_path('invalid_Canon.jpg')

if __name__ == "__main__":
    main()

The file invalid_Canon.jpg causes problems to Exiv2, so running the script gives this:

** (process:30414): CRITICAL **: Directory Canon with 6144 entries considered invalid; not read.

If I uncomment the page = line I get this:

[30508:30508:0620/184051.601309:ERROR:browser_main_loop.cc(278)] <unknown>: Directory Canon with 6144 entries considered invalid; not read.

KCrash: Application 'python3.6' crashing...
KCrash: Attempting to start /usr/lib64/libexec/drkonqi from kdeinit
sock_file=/run/user/1026/kdeinit5__0

[1]+  Stopped                 python3 webengine_test.py

The error now appears to be from browser_main_loop.cc, which is part of the Chromium browser used in QtWebEngineWidgets. I expect Chromium also uses GObject, so maybe I have a clash of different library versions. Or something.

jim-easterbrook commented 5 years ago

A workaround is to use QtWebKit, if it's available on your operating system. Edit the Photini config file and set using_qtwebengine = False.

jim-easterbrook commented 5 years ago

Even after that I'm still getting occasional crashes on exit if I have any map tabs enabled. Probably something to do with object destruction, but with WebKit, JavaScript, Qt, and GObject in the mix it's hard to track down. Especially as it happens about once in a dozen times.

jim-easterbrook commented 5 years ago

Aaaarrrrgh! The PyQt documentation shows how to avoid this problem. Previously I'd set sip.setdestroyonexit to solve it, now it seems to be a cause! I think commit 38b9f49 finally nails the crash on exit problem. Until next time. https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit

The misreporting of GLib errors when using QtWebEngine remains unsolved.