Search code examples
androidgstreamerglib

Why would setting G_DEBUG = fatal-warnings not cause an app using GLib to abort on Android?


Background: I'm converting a pure Android sample application (found here) that uses GStreamer's WebRTC module to Xamarin. The pure JAVA sample application I'm converting works nicely, as is expected. But, when porting the code over to Xamarin, I am hit with a number of GLib assertion failures that have confused me for a day or two. After several attempts, my last resort is now to break in a debugger when they occur so that I can begin to understand the nature of them.

The messages I get are:

  • g_error_new_literal: assertion 'message != NULL' failed
  • g_error_free: assertion 'error != NULL' failed

Also, interspersed in the assertion failures is this message (which I think is the ultimate culprit):

Conversion from character set “en-US” to “UTF-8” is not supported

Problem: So, after much reading, I've learned the GLib has the ability to abort on assertion failures (from here, here, and here). The problem is, running the application with

setenv("G_DEBUG", "fatal-criticals", 1);

or

setenv("G_DEBUG", "fatal-warnings", 1);

....executed from the first line in JNI_Load does not cause the application to terminate or break at all. In fact, everything proceeds as normal when ran from the Visual Studio debugger. Am I missing something? Is it required to run the application under gbd in order for it to terminate, or can I just run it via Visual Studio and expect it to break for me?

Thanks in advance.


Solution

  • I suspect that GLib reads that environment variable as soon as it is loaded, so you are probably writing it too late for it to have any effect. Try running your program with G_DEBUG=fatal-warnings in the environment when it is already started.

    (You don't need to use a debugger for that setting to take effect.)