Created attachment 75034 [details] PDF test case Originally reported in https://bugzilla.gnome.org/show_bug.cgi?id=659730 "[...] there are some documents, which after a text is selected in evince make it freeze. The same documents can be opened and scrolled as long as a text selecting tool is not used. How to reproduce the bug: - Open one of the above pdf documents and try to select text Note: If the selected text is a word or a line , the application freezes for a while and then continues to work. If a paragraph or more is selected it totaly freezes and even slows down the whole machine." Another comment: "Program received signal SIGINT, Interrupt. 0x1022441d in CairoOutputDev::drawImageMaskPrescaled(GfxState*, Object*, Stream*, int, int, bool, bool, bool) () from /usr/lib/libpoppler-glib.so.6 (gdb) thread apply all bt Thread 1 (Thread 0xb7741870 (LWP 14689)) #0 CairoOutputDev::drawImageMaskPrescaled(GfxState*, Object*, Stream*, int, int, bool, bool, bool) from /usr/lib/libpoppler-glib.so.6 #1 CairoOutputDev::drawImageMask(GfxState*, Object*, Stream*, int, int, bool, bool, bool) from /usr/lib/libpoppler-glib.so.6 #2 Gfx::doImage(Object*, Stream*, bool) from /usr/lib/libpoppler.so.13 #3 Gfx::opXObject(Object*, int) from /usr/lib/libpoppler.so.13 #4 Gfx::execOp(Object*, Object*, int) from /usr/lib/libpoppler.so.13 #5 Gfx::go(bool) from /usr/lib/libpoppler.so.13 #6 Gfx::display(Object*, bool) from /usr/lib/libpoppler.so.13 #7 ?? from /usr/lib/libpoppler-glib.so.6 #8 _cairo_user_scaled_glyph_init at /build/buildd/cairo-1.10.2/src/cairo-user-font.c line 158 #9 _cairo_scaled_glyph_lookup at /build/buildd/cairo-1.10.2/src/cairo-scaled-font.c line 2806 #10 _cairo_scaled_font_glyph_device_extents at /build/buildd/cairo-1.10.2/src/cairo-scaled-font.c line 2092 #11 _cairo_composite_rectangles_init_for_glyphs at /build/buildd/cairo-1.10.2/src/cairo-composite-rectangles.c line 189 #12 _cairo_image_surface_glyphs at /build/buildd/cairo-1.10.2/src/cairo-image-surface.c line 4035 #13 _cairo_surface_show_text_glyphs at /build/buildd/cairo-1.10.2/src/cairo-surface.c line 2625 #14 _cairo_gstate_show_text_glyphs at /build/buildd/cairo-1.10.2/src/cairo-gstate.c line 1981 #15 cairo_show_glyphs at /build/buildd/cairo-1.10.2/src/cairo.c line 3509 #16 CairoOutputDev::endString(GfxState*) from /usr/lib/libpoppler-glib.so.6 #17 TextSelectionPainter::visitWord(TextWord*, int, int, PDFRectangle*) from /usr/lib/libpoppler.so.13 #18 TextWord::visitSelection(TextSelectionVisitor*, PDFRectangle*, SelectionStyle) from /usr/lib/libpoppler.so.13 #19 TextLine::visitSelection(TextSelectionVisitor*, PDFRectangle*, SelectionStyle) from /usr/lib/libpoppler.so.13 #20 TextBlock::visitSelection(TextSelectionVisitor*, PDFRectangle*, SelectionStyle) from /usr/lib/libpoppler.so.13 #21 TextPage::visitSelection(TextSelectionVisitor*, PDFRectangle*, SelectionStyle) from /usr/lib/libpoppler.so.13 #22 TextPage::drawSelection(OutputDev*, double, int, PDFRectangle*, SelectionStyle, GfxColor*, GfxColor*) from /usr/lib/libpoppler.so.13 #23 poppler_page_render_selection from /usr/lib/libpoppler-glib.so.6 #24 pdf_selection_render_selection at /build/buildd/evince-3.1.90.1/./backend/pdf/ev-poppler.cc line 1882 #25 ev_selection_render_selection at /build/buildd/evince-3.1.90.1/./libdocument/ev-selection.c line 47 #26 ev_pixbuf_cache_get_selection_surface at /build/buildd/evince-3.1.90.1/./libview/ev-pixbuf-cache.c line 989 #27 merge_selection_region at /build/buildd/evince-3.1.90.1/./libview/ev-view.c line 6286 #28 compute_selections at /build/buildd/evince-3.1.90.1/./libview/ev-view.c line 6384 #29 selection_update_idle_cb at /build/buildd/evince-3.1.90.1/./libview/ev-view.c line 3943 #30 g_idle_dispatch at /build/buildd/glib2.0-2.29.92/./glib/gmain.c line 4801 #31 g_main_dispatch at /build/buildd/glib2.0-2.29.92/./glib/gmain.c line 2441 #32 g_main_context_dispatch at /build/buildd/glib2.0-2.29.92/./glib/gmain.c line 3011 #33 g_main_context_iterate at /build/buildd/glib2.0-2.29.92/./glib/gmain.c line 3089 #34 g_main_loop_run at /build/buildd/glib2.0-2.29.92/./glib/gmain.c line 3297 #35 gtk_main at /build/buildd/gtk+3.0-3.1.90/./gtk/gtkmain.c line 1367 #36 main at /build/buildd/evince-3.1.90.1/./shell/main.c line 331 " However, I have not been able to get Evince or poppler-glib-demo frozen. However, the selection is slow and it seems to select some blocks (squares) that involves 2 or 3 lines.
I forgot to mention: I tested with poppler-glib-demo from df3556240 (master) and cairo 1.12.14 (0dac37c41).
Probably a duplicate of https://bugs.freedesktop.org/show_bug.cgi?id=54939
Created attachment 76226 [details] [review] Set text matrix when painting selection The freezing is cairo allocating huge surfaces because the font size and matrix are scaled too large. This patch saves the current transformation matrix so it can be applied when the selection is painted.
By the way, does anybody else think we should just deprecate the glib frontend's poppler_page_render_selection function and have evince use poppler_page_get_selected_region and draw the selection boxes itself? The only advantage I can think of for the current method is that we can change the color of the text when it is selected, but I'm not sure that is worth the trouble.
Any comments on this patch?
Carlos seems to be quite busy lately, any other of the glib guys around?
While with this patch, evince no longers tries to allocate huges amounts of memory (and hence it no longer freezes), the rendering of the selection still seems broken (in my testing). Jason, do you get good selection after applying your patch with the test case proposed by Germán?
Created attachment 76923 [details] Screenshot showing the issue with text selected
(In reply to comment #7) > While with this patch, evince no longers tries to allocate huges amounts of > memory (and hence it no longer freezes), the rendering of the selection > still seems broken (in my testing). Jason, do you get good selection after > applying your patch with the test case proposed by Germán? José, The rendering of the selection could be an issue with Type3 fonts. See https://bugs.freedesktop.org/show_bug.cgi?id=54939 and compare with the screenshot I attached on this bug.
*** Bug 54945 has been marked as a duplicate of this bug. ***
So the problem is not with the patch, but with the fact that for the test case, the Text output is completely broken... Just run pdftotext on the test case to see what I mean. So the missing glyphs are just because in the "text detected" by poppler, there is a space! and since we visit words to render selections, it just does not work... That means that I think that the patch is doing the right thing, and fixing the fact that the text in the test case should give us good selections for this file.
(In reply to comment #11) > So the problem is not with the patch, but with the fact that for the test > case, the Text output is completely broken... Just run pdftotext on the test > case to see what I mean. So the missing glyphs are just because in the "text > detected" by poppler, there is a space! and since we visit words to render > selections, it just does not work... > > That means that I think that the patch is doing the right thing, and fixing > the fact that the text in the test case should give us good selections for > this file. I do not disagree with you. I am only saying there are two different bugs. The one related with slowness (and memory) and one related with the glyphs shown when the text is selected. This bug is about the former. The latter, I think, is related to https://bugs.freedesktop.org/show_bug.cgi?id=12980 and/or https://bugs.freedesktop.org/show_bug.cgi?id=60243 (see comment 4). IMVHO, the patch fixes this particular bug (slowness and memory).
(In reply to comment #12) > [...] > This bug is about the former. The latter, I think, is related to > https://bugs.freedesktop.org/show_bug.cgi?id=12980 and/or > https://bugs.freedesktop.org/show_bug.cgi?id=60243 (see comment 4). Here I meant: https://bugs.freedesktop.org/show_bug.cgi?id=60243#c4 All these bugs with ugly text selection have in common Type3 fonts.
I agree they are different bugs, the patch looks good, I've just pushed it to both branches. Sorry for delay reviewing it.
*** Bug 12980 has been marked as a duplicate of this bug. ***
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.