Closed diamondburned closed 2 years ago
GTK 4.6 changed a bunch of things around sizing: https://blog.gtk.org/2021/12/03/sizable-news/. It doesn't feel like that should result in an outright crash though, but maybe it provides a starting point. There's some bits and bobs in the newsfiles too: https://download.gnome.org/sources/gtk/4.6/
Ah, this seems helpful. I like the changes, but it seems like they don't like some of the sizing hacks that I put in place.
I've managed to get a stack trace of the widget that's causing the bug:
0x7ff009f32990: goroutine 1 [running, locked to thread]:
runtime/debug.Stack()
/nix/store/89l684ydhgb4da9qqvbd2v2367sf1s2f-go-1.18/share/go/src/runtime/debug/stack.go:24 +0x65
github.com/diamondburned/gotk4/pkg/core/intern.newBox(0x7ff009f32990)
/home/diamond/Scripts/gotk4/gotk4/pkg/core/intern/intern.go:60 +0x66
github.com/diamondburned/gotk4/pkg/core/intern.Get(0x7ff009f32990, 0x1)
/home/diamond/Scripts/gotk4/gotk4/pkg/core/intern/intern.go:143 +0x133
github.com/diamondburned/gotk4/pkg/core/glib.newObject(...)
/home/diamond/Scripts/gotk4/gotk4/pkg/core/glib/glib.go:583
github.com/diamondburned/gotk4/pkg/core/glib.Take(...)
/home/diamond/Scripts/gotk4/gotk4/pkg/core/glib/glib.go:560
github.com/diamondburned/gotk4/pkg/gtk/v4.NewBox(0x1, 0x0)
/home/diamond/Scripts/gotk4/gotk4/pkg/gtk/v4/gtkbox.go:138 +0x65
github.com/diamondburned/gotktrix/internal/app/messageview/message.messageViewer.cozyMessage({{0x2112ea0, 0xc000ad7860}, {0x2114658, 0xc0009f5860}, {0x2110fc8, 0xc000fdb2c0}}, 0xc000fdb2c0)
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/message/cozy.go:70 +0x45e
github.com/diamondburned/gotktrix/internal/app/messageview/message.NewCozyMessage({0x2114658?, 0xc0009f5860?}, {0x2112ea0?, 0xc000ad7860?}, {0x2110fc8?, 0xc000fdb2c0?}, {0x2120848?, 0xc000b0cde0?})
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/message/message.go:98 +0x12a
github.com/diamondburned/gotktrix/internal/app/messageview.(*Page).resetMessage(0xc000ad7860, {0xc000c7c800, 0x32}, {0xc0008269c0, {0x2110fc8, 0xc000fdb180}, 0x0, {0x2120848, 0xc000b0cde0}, {0xc0007cacc0, ...}})
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/page.go:786 +0x1c5
github.com/diamondburned/gotktrix/internal/app/messageview.(*Page).resetMessageIx(0xc000ad7860, 0x1d)
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/page.go:760 +0xf6
github.com/diamondburned/gotktrix/internal/app/messageview.(*Page).setMessage(0xc000ad7860, {0xc000c7c480?, 0x8?}, {0xc000f15c20, {0x2110fc8, 0xc000fdb2c0}, 0x0, {0x0, 0x0}, {0x0, ...}})
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/page.go:747 +0xe5
github.com/diamondburned/gotktrix/internal/app/messageview.(*Page).onRoomEvent(0xc000ad7860, {0x2110fc8, 0xc000fdb2c0})
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/page.go:720 +0x2a5
github.com/diamondburned/gotktrix/internal/app/messageview.(*Page).Load.func1.1()
/home/diamond/Scripts/gotk4/gotktrix/internal/app/messageview/page.go:873 +0xa6
github.com/diamondburned/gotk4/pkg/core/glib._gotk4_sourceFunc(0x1a7b)
/home/diamond/Scripts/gotk4/gotk4/pkg/core/glib/glib.go:328 +0xd9
github.com/diamondburned/gotk4/pkg/gio/v2._Cfunc_g_application_run(0x5347290, 0x1, 0x7ff008002020)
_cgo_gotypes.go:5619 +0x4c
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run.func3(0xc000779f80?, 0x8?, 0x7ff008002020?)
/home/diamond/Scripts/gotk4/gotk4/pkg/gio/v2/gapplication.go:1619 +0x71
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run(0xc0004fe1f8, {0xc0001181f0?, 0x1, 0x1})
/home/diamond/Scripts/gotk4/gotk4/pkg/gio/v2/gapplication.go:1619 +0x1d8
github.com/diamondburned/gotkit/app.(*Application).Run(0xc0001ea280, {0x2114658, 0xc000693b90}, {0xc0001181f0, 0x1, 0x1})
/home/diamond/go/pkg/mod/github.com/diamondburned/gotkit@v0.0.0-20220429055254-0e11be4d973f/app/app.go:237 +0x189
github.com/diamondburned/gotkit/app.(*Application).RunMain(0x2118f78?, {0x2114658?, 0xc000693b90?})
/home/diamond/go/pkg/mod/github.com/diamondburned/gotkit@v0.0.0-20220429055254-0e11be4d973f/app/app.go:242 +0x38
main.main()
/home/diamond/Scripts/gotk4/gotktrix/main.go:129 +0x189
size-request
debug output:
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 38 is minimum 650 and natural: 650 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 76 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 57 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 47 is minimum 650 and natural: 650 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 52 is minimum 650 and natural: 650 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 55 is minimum 650 and natural: 650 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 56 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox width for height: -1 is minimum 31 and natural: 650 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: 396 is minimum 56 and natural: 56 (hit cache: no)
[0x7ff009f32990] GtkBox width for height: -1 is minimum 31 and natural: 650 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 38 is minimum 650 and natural: 650 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 76 is minimum 331 and natural: 331 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 154 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 310 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 622 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 1246 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 2494 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 4990 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 9982 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 19966 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 39934 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 79870 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 159742 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 319486 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 638974 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 1277950 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 2555902 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 5111806 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 10223614 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 20447230 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 40894462 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 81788926 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 163577854 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 327155710 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 654311422 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 1308622846 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 939524094 is minimum 331 and natural: 331 (hit cache: yes)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 1879048190 is minimum 331 and natural: 331 (hit cache: no)
[0x7ff009f32990] GtkBox height for width: -1 is minimum 38 and natural: 38 (hit cache: yes)
[0x7ff009f32990] GtkBox width for height: 2147483646 is minimum 331 and natural: 331 (hit cache: no)
Seems like it's stuck in this section of code:
/* total_size > available happens when we last ran for values too big,
* rerun for the correct value min == max in that case */
while (min < max || total_size > available)
{
int test;
if (max == G_MAXINT)
test = min * 2; // size multiplied by 2 here
else
test = (min + max) / 2;
total_size = 0;
for (i = 0; i < n_sizes; i++)
{
gtk_widget_measure (sizes[i].data,
orientation,
test,
&sizes[i].minimum_size, &sizes[i].natural_size,
NULL, NULL);
total_size += sizes[i].minimum_size;
}
if (total_size > available)
min = test + 1;
else
max = test;
}
Inspecting the call to distribute_remaining_size
more carefully:
int min_size = 0, child_min_size;
int n_inconstant = 0;
/* Retrieve desired size for visible children */
for (i = 0, child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
if (!gtk_widget_should_layout (child))
continue;
if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
{
gtk_widget_measure (child,
self->orientation,
-1,
&sizes[i].minimum_size, &sizes[i].natural_size,
NULL, NULL);
sizes[i].data = child;
g_assert (available >= sizes[i].minimum_size);
available -= sizes[i].minimum_size;
i++;
}
else
{
gtk_widget_measure (child,
OPPOSITE_ORIENTATION (self->orientation),
-1,
&child_min_size, NULL,
NULL, NULL);
min_size = MAX (min_size, child_min_size);
n_inconstant++;
sizes[nvis_children - n_inconstant].data = child;
}
}
available = distribute_remaining_size (sizes + nvis_children - n_inconstant,
n_inconstant,
self->orientation,
available,
min_size,
G_MAXINT);
along with gdb's output:
#4 0x00007ffff76d0ccb in distribute_remaining_size (max=<optimized out>, min=1308622847, available=31, orientation=GTK_ORIENTATION_HORIZONTAL, n_sizes=<optimized out>, sizes=<optimized out>) at ../gtk/gtkboxlayout.c:332
it can be seen that min_size
here is 1308622847
, which is a ridiculously large number. This is probably caused by min_size = MAX (min_size, child_min_size)
, so child_min_size
is presumably also that large.
Further inspection gives
min_size = <optimized out>
child_min_size = 38
so it actually isn't child_min_size
.
One thing worth noting is that child_min_size
is not initialized to 0. The value may have been some randomly high number.
MR https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4670 should fix this. It doesn't seem like this is going to make it into a release that's widely available anytime soon, though.
Can confirm that above MR fixes this regression. Console outputs
2022/04/30 16:25:10 Critical: Gtk: GtkBox 0x7f19cdf275f0 reports a minimum width of 31, but minimum width for height of 1048576 is 331. Expect overlapping widgets.
yet no overlapping is visible:
Closing this issue since it's fixed.
I have no idea why.
Known:
Render{HTML,Text}
functions make it work. UsingRenderText
only makes it crash even though it's a simplegtk.Label
.Possible ways to debug:
gcc
without it omitting registers.-O0
, maybe adddebug = true
intodefault.nix
's overlay.git bisect
maybe?gdb backtrace
``` #0 g_logv (log_domain=0x7ffff7a6d355 "Gtk", log_level=G_LOG_LEVEL_CRITICAL, format=