Periodic crashes with a cairo_surface_reference error message
What operating system are you using?
Linux (pop_os, 22.04)
What version of Tartube are you using?
2.4.386 (.deb version)
I'm periodically encountering a crash ~~when downloading or checking channels~~ whilst the application is running. The terminal output when it crashes looks like this:
python3: ../../../../src/cairo-surface.c:930: cairo_surface_reference: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.
Aborted (core dumped)
~~Whilst cairo_surface seems to suggest a graphical root cause, it is oddly consistent when it comes to channels. Either a particular channel crashes repeatedly, or there's never a crash with it. An example of one that I see frequent crashes with: https://www.youtube.com/channel/UCuppnYXlAo7r7IhVigrVAfQ~~
Edit: I've also seen it crash with the same cairo message whilst sitting idly, not downloading or checking anything.
I've seen references to an option for assuming GTK is broken in the settings when searching for this issue, but I can't find that option in my version of tartube. Has it been removed?
I have seen this same crash, but very rarely, so it has not been possible to isolate the cause.
The error is complaining that the cairo context (a blob of data used for drawing the window) is invalid, as suggested by this issue.
Unfortunately, nothing in the Tartube code uses Cairo directly, so I don't know if it's an issue in my code or if it's a bug buried deep in the Gtk libraries.
You could try these things, and report back to me if you notice any difference in behaviour:
- While checking/downloading, in the Videos tab select an empty folder, so that no videos are visible
- In the main menu, use the Switch View button to use a simpler layout (or use the menu, e.g. Media > Switch between views > Basic list)
I've seen references to an option for assuming GTK is broken in the settings when searching for this issue, but I can't find that option in my version of tartube. Has it been removed?
Yes, it was an entirely different issue (tl;dr Gtk is not thread-safe), which was fixed some time ago.
After some more testing, I've been able to trigger the crash both idling on the Videos tab with no channel selected (so no thumbnails or anything) as well as idling on the Output tab. No luck in finding a consistent trigger so far, it is very inconsistent. Sometimes it'll crash twice in a few minutes, other times it'll idle for a day or more without issue. Will keep experimenting with it.
If you like, you can try running v2.3.367, which was the last version to include extensive debug messages throughout the code.
The debug messages must be turned on by editing one of the source code files, ..\msys64\home\user\tartube\tartube\mainapp.py.
Line 116
DEBUG_FUNC_FLAG = False
...must be changed to this:
DEBUG_FUNC_FLAG = True
You should then run Tartube from inside a terminal window, so you can see the generated output. Run the application ..\msys64\mingw64.exe, then in the new window, type these commands:
cd /home/user/tartube
python3 tartube/tartube
Update: After dropping back to 2.3.367 and running it for a while, including downloading a few hundred videos, I didn't see any crashes. I then switched back to 2.4.386, started with a blank slate, and again didn't see any crashes over the course of a couple days. However, when I load up my fairly large (15K+ videos) real database, I see regular crashes. Seems unlikely to be a scaling issue causing a windowing crash since it never tries to render the entire set of videos. Perhaps one or more of the resources is broken? Something like a corrupted thumbnail that causes cairo to throw errors, perhaps?
I let v2.3.367 run for about six days without interruptions, and didn't see any crashes. It might be the case that we need a large database. I have one of those, so I'll try running v2.3.367 again and we'll see what happens.
I'm also having the same problem with the cairo_surface_reference error. Any updates on this bug?
Sorry, I have not been able to make any progress.
I just tired the latest v2.4.429 tartube.
Unfortunately the same crash occurs after a while checking for new videos (not downloading) in various channels.
(tartube:26011): Gdk-CRITICAL **: 17:19:19.395: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
python3: ../../../../src/cairo-surface.c:930: cairo_surface_reference: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.
Aborted
I have an idea about this, perhaps you could try v2.4.433 (uploaded only to Github and Pypi).
Sorry for the late reply, I've only just had a chance to try again.
I installed v2.4.433 using a fresh python venv to reduce the risk of something interfering.
Unfortunately it has the same problem:
cairo_surface_reference: Assertion CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.`
I think I have found the cause of these crashes, and I have uploaded a fix as v2.4.438.
The new code is only uploaded here to github (not to PyPI, as usual).
If any of you have the time to test it, over the next few days, then I would be happy to hear about the results.
I have also added some detailed deub messages. If you run Tartube from a terminal window, you can see them. If Tartube crashes, please show me the last 50 or so lines from your terminal.
Fixed in v2.5.0.
Hi @axcore
I downloaded and installed the v2.5.0 deb package and let Tartube check all channels (not download) and got the same error again.
(tartube:4295): Gdk-CRITICAL **: 20:33:10.640: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
python3: ../../../../src/cairo-surface.c:930: cairo_surface_reference: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.
Aborted
Is there a way to turn on debugging? tartube --help-all doesn't show anything obvious.
Or will I need to compile from source?
Thanks again for your efforts.
Is there a way to turn on debugging?
Long answer: in the file /tartube/mainapp.py, change the initial values of DEBUG_FUNC_FLAG and DEBUG_NO_TIMER_FUNC_FLAG from False to True (note the capitalisation).
In the files /tartube/mainwin.py and /tartube.downloads.py, change the initial value of DEBUG_FUNC_FLAG from False to True.
Short answer: download and run code from the debug branch, which already has those changes. On Linux, Tartube's source code can be run directly, no compiling or installation required.
Thanks @axcore,
Because the logs become huge quickly, 100MB's within 10 minutes or so. So I compressed the logs as follows [1], in case anyone else needs to do the same:
$ python3 tartube/tartube 2>&1 | tee | zcat > tartube_debug.log.gz
There are a bunch of warnings at the start:
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:154:27: The style property GtkButton:image-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:155:26: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:585:27: The style property GtkButton:image-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:586:28: The style property GtkWidget:interior-focus is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:587:28: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.291: Theme parsing error: gtk-widgets.css:588:26: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.292: Theme parsing error: gtk-widgets.css:1345:25: The style property GtkRange:slider-width is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.292: Theme parsing error: gtk-widgets.css:1346:25: The style property GtkRange:stepper-size is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.292: Theme parsing error: gtk-widgets.css:1347:34: The style property GtkScrollbar:min-slider-length is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.292: Theme parsing error: gtk-widgets.css:1348:28: The style property GtkRange:stepper-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(tartube:30653): Gtk-WARNING **: 22:15:20.292: Theme parsing error: gtk-widgets.css:1349:34: The style property GtkRange:trough-under-steppers is deprecated and shouldn't be used anymore. It will be removed in a future version
2024-01-08 22:15:20 app 136 __init__
2024-01-08 22:15:20 app 2627 do_startup
2024-01-08 22:15:20 app 3486 do_activate
2024-01-08 22:15:20 app 3588 start
2024-01-08 22:15:20 app 9766 setup_paths
2024-01-08 22:15:20 app 9917 auto_detect_paths
2024-01-08 22:15:20 app 10218 find_sound_effects
2024-01-08 22:15:20 mwn 100 __init__
...
(tartube:30653): Gdk-CRITICAL **: 22:15:21.955: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
...
Then the crash happens without any other warnings/errors about 1 hour later whilst tartube checks the channels (not downloading):
2024-01-08 23:27:55 dld 11406 is_child_process_alive
2024-01-08 23:27:55 dld 6227 read_child_process
2024-01-08 23:27:55 dld 5781 is_child_process_alive
2024-01-08 23:27:55 dld 6227 read_child_process
2024-01-08 23:27:55 dld 5781 is_child_process_alive
2024-01-08 23:27:55 dld 6227 read_child_process
2024-01-08 23:27:55 dld 5781 is_child_process_alive
2024-01-08 23:27:55 dld 2941 fetch_next_item
2024-01-08 23:27:55 dld 855 check_workers_all_finished
python3: ../../../../src/cairo-surface.c:930: cairo_surface_reference: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.
- https://stackoverflow.com/questions/15673359/tee-to-a-compressed-file
I would guess that the initial Theme parsing errors are a result of Gtk complaining about your desktop theme, and are not caused by Tartube itself. You can test this for yourself by trying some other desktop themes. If that doesn't work, try running this test script and see if it produces the same problem.
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
Save this as a file called test.py, and then run it by typing
python3 test.py
Tartube's debug output shows the name of each function, as it is called. But a Gtk crash will not happen immediately. Usually I have to go back a hundred lines or so to find the piece of code that's causing the problem.
If you can, please show the last 200-300 lines of output before the crash.
Please find attached the last 400 lines. tartube_debug.400.log
Sorry, I still cannot reproduce this, and the debug log you provided does not provide any clues.
If you can tell me exactly which Linux distribution you're running, and exactly which desktop them you have selected for it, then I will test that directly.
Sorry missed your test.py message, here is the logs:
$ python3 test_gtk_theme.py 2>&1 | tee test_gtk_theme.log
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:154:27: The style property GtkButton:image-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:155:26: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:585:27: The style property GtkButton:image-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:586:28: The style property GtkWidget:interior-focus is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:587:28: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.276: Theme parsing error: gtk-widgets.css:588:26: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.277: Theme parsing error: gtk-widgets.css:1345:25: The style property GtkRange:slider-width is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.277: Theme parsing error: gtk-widgets.css:1346:25: The style property GtkRange:stepper-size is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.277: Theme parsing error: gtk-widgets.css:1347:34: The style property GtkScrollbar:min-slider-length is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.277: Theme parsing error: gtk-widgets.css:1348:28: The style property GtkRange:stepper-spacing is deprecated and shouldn't be used anymore. It will be removed in a future version
(test_gtk_theme.py:11155): Gtk-WARNING **: 18:09:32.277: Theme parsing error: gtk-widgets.css:1349:34: The style property GtkRange:trough-under-steppers is deprecated and shouldn't be used anymore. It will be removed in a future version
I'm using Devuan, which is based on Debian.
$ cat /etc/os-release
PRETTY_NAME="Devuan GNU/Linux 5 (daedalus)"
NAME="Devuan GNU/Linux"
VERSION_ID="5"
VERSION="5 (daedalus)"
VERSION_CODENAME="daedalus"
ID=devuan
ID_LIKE=debian
HOME_URL="https://www.devuan.org/"
SUPPORT_URL="https://devuan.org/os/community"
BUG_REPORT_URL="https://bugs.devuan.org/"
And here is the Xfce details.
Xfce Version: 4.18 GTK vresion: 3.24.38
I installed Devuan (Daedalus), XFCE, and I ran Tartube v2.5.0 for about 24 hours, downloading videos continuously. I didn't experience any crashes. I did see the same "Theme parsing error" warnings both from Tartube, and from the test python script I described above.
Sorry, I don't know what else to suggest.
Thank you so much for going to the trouble of installing Devuan and testing.
There must be something wrong with my setup. I'll see if can work out why and report back if I succeed.
Try running the test script (or just run Tartube) with a different desktop theme. If they all produce the same warnings, then we will know that it's not a problem with the themes themselves.
I've been getting this crash too for quite some time on multiple 2.4 updates (currently on 2.4.429), and finally bothering now to look in to it.
System info: Ubuntu 20.04 (updating is on the todo list...) XFCE 4.14 GTK 3.24.20 deb install
The behavior I have seen is that tartube will run fine for a while, sometimes for over a month straight, either continuously or restarts, then suddenly will have this crash and will keep doing so every 5-90 minutes regardless of what it is doing of visibility status (window in foreground, background, minimize, or closed to tray). This behavior will remain constant till reboot where there is a chance it will restart this cycle and run fine for at least a week or two.
Only looking in to the issue now cause its happened 3 times in 5 minutes (though the 4 run kept going for 30+ minutes while doing this research and this report). Just updated to 2.5.0, will report back later how that goes and if it crashes again, will switch to debug branch while its still repoing this issue.
The crashing continued on 2.5.0 and I was unable to get the debug version to run.
I'm 99% that I understand the cause of this crash and its solution; it should be fixed in v2.5.040 which is available for download now. If not, feel free to re-open the issue.