Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLib-GObject-CRITICAL: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed #139

Closed
WalterWoshid opened this issue Mar 18, 2022 · 6 comments

Comments

@WalterWoshid
Copy link

WalterWoshid commented Mar 18, 2022

PHP Version: 8.1.3
PHP ini: ffi.enable=true Also true for php -i
Framework: Laravel 9.4.1
Environment: WSL 2 Docker
Docker OS: Ubuntu-20.04
libvips-dev: 8.10.5-2ubuntu1
jcupitt/vips: v2.0.0

I'm receiving this error in my console, while trying to run the below code.

(.:21): GLib-GObject-CRITICAL **: 22:13:34.813: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed

$image = \Jcupitt\Vips\Image::newFromFile(resource_path('HQ-Heidi.png'));
$width = $image->width;
$height = $image->height;

It is repeating very fast and also I have to stop PHP, because the request runs for too long.

Edit:
The beginning of the logs

(.:22): GLib-GObject-WARNING **: 22:20:57.385: cannot register existing type 'VipsObject'


(.:22): GLib-CRITICAL **: 22:20:57.385: g_once_init_leave: assertion 'result != 0' failed


(.:22): GLib-GObject-CRITICAL **: 22:20:57.385: g_type_register_static: assertion 'parent_type > 0' failed


(.:22): GLib-CRITICAL **: 22:20:57.385: g_once_init_leave: assertion 'result != 0' failed

EDIT: FIXED

I fixed it by installing the pecl extension for vips

sudo pecl install vips
# Add vips.so to your php.ini
sudo echo 'extension="vips.so"' > /etc/php/8.1/cli/conf.d/20-vips.ini

I will let this issue stay open, either this should be documented or there should be a fix?

@jcupitt
Copy link
Member

jcupitt commented Mar 19, 2022

Hi @WalterWoshid,

I've not tried php-vips2 in WSL yet, I'll have a quick go. It might be a lavarel issue (perhaps it's not starting up the extension correctly?). The PECL extension should not be necessary, though perhaps that's ensuring that init happens in this case.

Did you try the example programs? Eg.:

https://github.com/libvips/php-vips/blob/master/examples/watermark-text.php

I see:

$ ./watermark-text.php ~/pics/PNG_transparency_demonstration.png x.png "hello world!"

To make:

x

@jcupitt
Copy link
Member

jcupitt commented Mar 19, 2022

Ah it seems I can't install WSL2, that's a shame. I run win10 under virtualbox, and it doesn't support nested VMs.

So (just guessing) I think perhaps what's happening is that Lavarel is not pulling in php-vips early enough. Is there some way to change the config to make the vendor autoload happen sooner? That might fix it.

@lucasnetau
Copy link

I've trigger the same assertion with a different environment:

GLib-GObject-CRITICAL **: 01:54:46.648: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed

Leading to a SIGSEV child 6 exited on signal 11 (SIGSEGV) after 669.163951 seconds from start

PHP Version: 8.0.17
PHP ini: ffi.enable=true
Framework: SlimPHP
Environment: Docker (Debian 11)
Docker OS: Amazon Linux release 2 (Karoo)
libvips-dev: 8.10.5-2
jcupitt/vips: v2.0.1

It does not always occur, only on some requests, identical requests complete fine.

@lucasnetau
Copy link

Triggered it a second time, this time with another GLib error

(.:1965): GLib-GObject-WARNING **: 02:11:06.006: cannot register existing type 'VipsObject'
(.:1965): GLib-CRITICAL **: 02:11:06.006: g_once_init_leave: assertion 'result != 0' failed
(.:1965): GLib-GObject-CRITICAL **: 02:11:06.006: g_type_register_static: assertion 'parent_type > 0' failed
(.:1965): GLib-CRITICAL **: 02:11:06.006: g_once_init_leave: assertion 'result != 0' failed

The two constructors I am use plus methods are:

Vips\Image::newFromBuffer
-> height
-> width

Vips\Image::thumbnail_buffer
-> height
-> width
-> writeToBuffer

@kleisauke
Copy link
Member

See: #142 (comment).

@kleisauke
Copy link
Member

libvips 8.13 ought to fix this. @WalterWoshid Would you be able to test again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants