revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

Uncaught Division_by_zero crash on window resize. (maxHeight vs flexGrow ?) #1025

Closed geoffder closed 1 year ago

geoffder commented 3 years ago
Uncaught exception:

  Division_by_zero

Raised at file "src/lib/HardCodedEncoding.re" (inlined), line 140, characters 11-14
Called from file "src/lib/Layout.re", line 1135, characters 25-147
Called from file "src/lib/Layout.re", line 291, characters 6-193
Called from file "src/lib/Layout.re", line 604, characters 6-199
Called from file "src/lib/Layout.re", line 1744, characters 12-206
Called from file "src/lib/Layout.re", line 291, characters 6-193
Called from file "src/lib/Layout.re", line 1806, characters 7-214
Called from file "src/UI/Render.re", line 70, characters 2-45
Called from file "src/Core/Window.re", line 395, characters 2-17
Called from file "list.ml", line 110, characters 12-15
Called from file "src/Core/App.re", line 298, characters 6-123
Called from file "packages/reason-sdl2/src/sdl2.re", line 823, characters 10-20
Called from file "packages/reason-sdl2/src/sdl2.re", line 269, characters 17-59
Called from file "packages/reason-sdl2/src/sdl2.re", line 269, characters 17-59
Called from file "src/main.ml", line 6, characters 2-65

I found this (closed on merge) issue https://github.com/revery-ui/revery/issues/180, which sounds pretty similar. I've never had it happen before now, when I set the Style maxHeight on an element that has flexGrow set (= 1). Removing either the flexGrow or maxHeight settings allows window resizing without the exception.

geoffder commented 3 years ago

Having experimented a bit more I can narrow it down a bit, it seems to only occur when all flexGrows in the box are 0, while the one with a corresponding maxHeight is set to 1. Setting each (or at least one of the others) to 1, then using a large flexGrow (like 100) for the one which is supposed to be taking up the space has allowed resizing while achieving the desired layout. e.g.

header: flexGrow 0
contents: flexGrow 1; maxHeight x
footer: flexGrow 0

Leads to the exception, while the following does not.

header: flexGrow 0 (or 1)
contents: flexGrow 100; maxHeight x
footer: flexGrow 1