After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752147 - glimagesink and textoverlay aren't friends on OS X
glimagesink and textoverlay aren't friends on OS X
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.4.5
Other Mac OS
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 22:42 UTC by Kyrylo V. Polezhaiev
Modified: 2018-05-05 11:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Crash of gst-launch-1.0 videotestsrc ! textoverlay ! glimagesink (11.62 KB, text/plain)
2015-07-08 22:42 UTC, Kyrylo V. Polezhaiev
  Details
WIP pango: init PangoFontMap and PangoContext when going to READY state (5.46 KB, patch)
2015-07-10 23:22 UTC, Julien Isorce
none Details | Review
pango: use fontconfig backend by default on all platforms (1.67 KB, patch)
2015-08-20 21:56 UTC, Julien Isorce
none Details | Review

Description Kyrylo V. Polezhaiev 2015-07-08 22:42:08 UTC
Created attachment 307111 [details]
Crash of gst-launch-1.0 videotestsrc ! textoverlay ! glimagesink

I have crash after

    gst-launch-1.0 videotestsrc ! textoverlay ! glimagesink

I have no crash for 

    gst-launch-1.0 videotestsrc ! textoverlay ! fakesink

or

    gst-launch-1.0 videotestsrc ! glimagesink

Something related to font typefaces in cocoa window creation inside gst_gl_window_cocoa_create_window.
Comment 1 Julien Isorce 2015-07-10 23:22:13 UTC
Created attachment 307285 [details] [review]
WIP pango: init PangoFontMap and PangoContext when going to READY state

videosink on osx may use NSFont to set title on their window:
initWithContentRect:rect styleMask: NSTitledWindowMask
    
This function will crash when using the custom NSApp loop
in glimagesink and osxvideosink:
[__NSCFType symbolicTraits]: unrecognized selector
[__NSFontTypefaceInfo _postscriptName]

The patch (even incomplete) seems to fix the problem. But I do not really understand what happens in the end :)
I thought it was because textoverlay inits its pango fontmap and pango context before initializing the NSApp. So I defer this in textoverlay from init to NULL_to_READY.

But then in a real cocoa app, even if I create textoverlay before the NSApp, the pipeline works and does not crash. So that's still not clear.

Note that the patch is incomplete, it is to start discussion and best way to fix this. If we do this way (READY_to_NULL) we will need to apply same logic for other pango elements.
Comment 2 Julien Isorce 2015-07-22 22:31:59 UTC
Should we mark this bug as blocker for 1.6 ? Since both osxvideosink and glimagesink crashes when pipeline contains textoverlay. (though osxvideosink is sometimes lucky)
Comment 3 Tim-Philipp Müller 2015-07-22 22:43:05 UTC
Well, feel free to mark it as blocker, but it doesn't mean it will actually get solved. Someone has to investigate and understand what's actually happening first, and then make a proper patch.
Comment 4 Kyrylo V. Polezhaiev 2015-07-22 23:03:28 UTC
Maybe let's integrate NSApp in Glib's main loop?

gst-launch-1.0 videotestsrc ! tee name=t ! glimagesink t. ! glimagesink t. ! glimagesink
Comment 5 Julien Isorce 2015-07-22 23:17:17 UTC
(In reply to Kyrylo V. Polezhaiev from comment #4)
> Maybe let's integrate NSApp in Glib's main loop?

Good point, that might be a solution and that could explain why nobody reported it before. If someone could try textoverlay ! glimagesink with cerbero that would be great (because it has the local NSApp/Glib fix locally https://bugzilla.gnome.org/show_bug.cgi?id=741450)
Though I am still not convinced this is really the problem: "even if I create textoverlay before the NSApp, the pipeline works and does not crash. So that's still not clear"

> 
> gst-launch-1.0 videotestsrc ! tee name=t ! glimagesink t. ! glimagesink t. !
> glimagesink

You are missing queues, also it seems gst-launch-1.0 videotestsrc ! tee ! glimagesink does not work atm but was working recently. I think someone already reported the problem on IRC but feel free to open a bug.
Comment 6 Kyrylo V. Polezhaiev 2015-07-22 23:33:08 UTC
oh, yes, forgot queues, shame for me.
Comment 7 Julien Isorce 2015-07-22 23:38:53 UTC
Since pango provides 2 backend on osx (QUARTZ named coretext and FREETYPE named fontconfig) we could use the later which seems to work:

"#if defined(__APPLE__) (and probably && !defined(GSTREAMER_GLIB_COCOA_NSAPPLICATION)) fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT)" instead of "fontmap = pango_cairo_font_map_get_default ();" here http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/ext/pango/gstbasetextoverlay.c#n319

See https://github.com/GNOME/pango/blob/master/pango/pangocairo-fontmap.c#L132 and https://github.com/GNOME/pango/blob/master/pango/pangocairo-fontmap.c#L74


Quick test:

PANGOCAIRO_BACKEND=fontconfig gst-launch-1.0 videotestsrc ! textoverlay text="hello" font-desc="Verdana bold 80px" ! glimagesink
Comment 8 Kyrylo V. Polezhaiev 2015-07-22 23:52:22 UTC
Oh, at least PANGOCAIRO_BACKEND=fontconfig helps here: https://bugzilla.gnome.org/show_bug.cgi?id=752148
Comment 9 Tim-Philipp Müller 2015-08-10 14:55:02 UTC
Demoting this, I don't think this is a blocker bug and as far as I know we only build the fontconfig backend in our OS/X builds anyway.

Not sure what to do about this. Is this really a bug in our plugin and not pango? Julien?
Comment 10 Julien Isorce 2015-08-20 21:53:40 UTC
(In reply to Tim-Philipp Müller from comment #9)
> Demoting this, I don't think this is a blocker bug and as far as I know we
> only build the fontconfig backend in our OS/X builds anyway.
> 
Are you sure ? I do not have a cerbero setup atm but http://cgit.freedesktop.org/gstreamer/cerbero/tree/recipes/cairo.recipe#n52 and nothing disable coretext backend in pango.recipe. (also https://github.com/GNOME/pango/blob/master/configure.ac#L372, https://github.com/GNOME/pango/blob/master/pango/pangocairo-fontmap.c#L85)
I am sure I am missing something since nobody reported the problem with cerbero before.

> Not sure what to do about this. Is this really a bug in our plugin and not
> pango? Julien?

I tend to say it is a bug in pango :) but honestly I do not know.
I do not see how cerbero disables the coretext/quartz backend. But if it really does then we should just tell textoverlay to use fontconfig on all platform :). So that visual results would be more consistent for the user as well. And to avoid visual artifacts, see https://bugzilla.gnome.org/show_bug.cgi?id=752148
Comment 11 Julien Isorce 2015-08-20 21:56:16 UTC
Created attachment 309772 [details] [review]
pango: use fontconfig backend by default on all platforms

If needed I can add a property named "cairo-backend" with values in {"auto", "coretext", "fontconfig", "win32"} (to be consistent with the getenv here https://github.com/GNOME/pango/blob/master/pango/pangocairo-fontmap.c#L74)

"auto" being to call pango_cairo_font_map_get_default. The property "cairo-backend" would have "fontconfig" as default value.
Comment 12 Joe Gorse 2016-03-04 05:35:27 UTC
FWIW, PANGOCAIRO_BACKEND=fontconfig will break gtk+3 apps in terrible ways. So don't set that by default or else you will get weird behavior and lots of these:
Gtk-WARNING **: drawing failure for widget 'GtkBox': out of memory
Comment 13 Nicolas Dufresne (ndufresne) 2016-03-04 17:18:59 UTC
The fontconfig backend is purely software, are you sure the issue you are seeing isn't another unrelated bug ?
Comment 14 Jan Schmidt 2018-05-05 11:20:26 UTC
Does anyone remember what should happen here, or has tested it lately?
Comment 15 Nicolas Dufresne (ndufresne) 2018-05-05 11:42:41 UTC
I think the main conclusion is that the pango / OSX support is/was massively broken. Sounds like not a GStreamer issue, updating Pango/Cairo in cerbero might be needed though.
Comment 16 Philippe Normand 2018-05-05 11:52:42 UTC
I can't reproduce this bug here with the 1.14.0 binaries shipped by HomeBrew.
I've been watching movies with external sub files for months using Glide, it works fairly well in general :)