mikke89 / RmlUi

RmlUi - The HTML/CSS User Interface library evolved
https://mikke89.github.io/RmlUiDoc/
MIT License
2.74k stars 299 forks source link

Hitting assert in `ContainerBox::CatchOverflow` #657

Closed Paril closed 16 hours ago

Paril commented 3 weeks ago

This isn't so much a bug, but it's been making development a bit difficult and I wanted to ask before just silencing the log level entirely; we're continuously hitting an assert in layout: RMLUI_ASSERT(available_space.x >= 0.f && available_space.y >= 0.f); It prints like 24 lines to the console when this happens - is this something to be worried about functionality-wise? The document looks & acts fine, but I'd like to understand what it's trying to tell me.

Here's the output of the parameters & locals:

  | Name | Value | Type
-- | -- | -- | --
◢ | content_overflow_size | {x=105.000000 y=144.000000 } | Rml::Vector2<float>
  | x | 105.000000 | float
  | y | 144.000000 | float
◢ | box | {content={x=-0.333332062 y=-1.00000000 } area_edges=0x00000204c61ef8f8 {0x00000204c61ef8f8 {26.6666660, ...}, ...} } | const Rml::Box &
  | ▶ content | {x=-0.333332062 y=-1.00000000 } | Rml::Vector2<float>
  | ▶ area_edges | 0x00000204c61ef8f8 {0x00000204c61ef8f8 {26.6666660, 26.6666660, 26.6666660, 26.6666660}, 0x00000204c61ef908 {...}, ...} | float[3][4]
  | max_height | 3.40282347e+38 | const float
◢ | available_space | {x=-0.333332062 y=3.40282347e+38 } | Rml::Vector2<float>
  | x | -0.333332062 | float
  | y | 3.40282347e+38 | float
▶ | padding_bottom_right | {x=0.00000000 y=0.00000000 } | Rml::Vector2<float>
  | padding_width | -0.333332062 | const float
mikke89 commented 3 weeks ago

Thanks for reporting this. I'd be very interested in a reproducer. And could you tell me which commit you are on? I believe this one is newer than 5.1, but I know you are not on the latest commits at least.

If the layout comes out fine, then I wouldn't be too worried about it. But obviously there is something going on here that we haven't accounted for, so we should solve this properly.

Paril commented 3 weeks ago

Yeah I'm on a mixed 5.1 with the re-layout fix. I haven't had time to check if 6.x solves the issue, and it doesn't appear to be causing any issues other than the console spam which I've just hid for now.

Do we have a function to quickly dump an entire document in a way that just puts everything in a single .rml doc with embedded styles and all? It might be possible for me to do that and send you that, since this repro requires a bit of code setup (it seems to happen when I set the preview in our vault-like menu).

mikke89 commented 3 weeks ago

Do we have a function to quickly dump an entire document in a way that just puts everything in a single .rml doc with embedded styles and all?

The closest thing we have is Element::GetRML, which you can call on the document itself. Unfortunately, this doesn't include any local style of the elements unless they were set in the document RML itself. However, that is a good idea to improve so I made a quick fix for that here ~(not fully tested): https://github.com/mikke89/RmlUi/commit/b368b6a85a40da2fbf9d527c2901364d5c6dbd4e~. Edit: Pushed to master: https://github.com/mikke89/RmlUi/commit/193d3e64f76204c8a30f826a1a2dfc3f53c7cc9a

In any case you will have to include your document RCSS and any external style files manually. It would be nice with a "dump everything" function.

Paril commented 3 weeks ago

Cool. I can cherry-pick this in, output a dump of the document live as it was happening, and send you additional information via your email (incl the rml/rcss src), if that's okay with you; I can't post it publicly as it involves an active game in development & NDA stuff.

mikke89 commented 3 weeks ago

Sounds great, thanks!

mikke89 commented 16 hours ago

I took a closer look at this one, and managed to reproduce the issue from the files you sent me.

I believe I fixed this, at least my reproducer. More generally, it's hard to guard against every possible floating point imprecision, but we'll just have to make a best effort and fix things as they appear.

Added the minimal reproducer as a test too so that we'll catch it again if something changes.

Paril commented 13 hours ago

Cool! Thanks