Dear all,
I am trying to make a latex editor in gjs; as a part of it, i’m trying to display pdf files. So far what I’m doing is to create a drawing area inside a scrolled window, set the size of the drawing area to the size of the whole document (such that the scrolling works), and connect to the draw signal to repaint the pdf with Poppler when scrolling. However, this process seems to eat a lot of memory (a few GB after scrolling through a 10-page document a few times). I guess I’m doing something wrong; I have managed to find a minimal non-working example for my problem (at least I hope it’s the same problem):
#!/usr/bin/gjs
imports.gi.versions.Gtk = "3.0";
const {Gtk} = imports.gi
Gtk.init(null)
let width = 400
let height = 600
let area = new Gtk.DrawingArea();
area.set_size_request(width, height);
area.connect('draw', (area, ctx) => {
});
const scroll = new Gtk.ScrolledWindow({ hexpand: true, vexpand: true });
scroll.add(area);
const win = new Gtk.Window({ defaultHeight: height, defaultWidth: width });
win.connect('destroy', () => { Gtk.main_quit(); });
win.add(scroll);
win.show_all();
Gtk.main();
When executing this code and resizing the window like crazy for a few minutes, the memory usage rapidly increases (and never decreases after). The closest thing related I found is this bug in Ruby, but here I have no problem without the scroll area.
So my question is: am I doing something wrong even in this tiny example or is this a bug?
Thanks a lot.
P.S. I have given up on Evince due to the lack of examples – I couldn’t figure out how to make synctex work, more specifically, how to jump to a given coordinate in the pdf and then highlight a given area.