oωo (owo-lib)

oωo (owo-lib)

17M Downloads

NullPointerException using scroll component

Zailer43 opened this issue · 4 comments

commented

I made a list in a flow layout with a custom component and it worked but I didn't see the whole list, so I put a scroll on it and now it crashes

owo_version=0.8.5+1.19

crashlog: https://gist.github.com/Zailer43/53117821b8c5eeac41ec361ea42aa630

commented

The problem you're running into here is that owo-ui is not thread-safe.

You're adding the children to the head list from a new Thread created in your ImageButtonWidget. If this happens while the UI is rendering, the component will try to render while being unmounted. That results in a crash, a component rendering without properly being mounted somewhere below a root component is not a valid state.

To fix your problem, all you need to do is wrap the call to this.onValueChanged() in a MinecraftClient.getInstance().execute(...) lambda to modify the UI on the client thread.

Cheers

commented

oh ok, sorry for the inconvenience

commented

This seems to me like a component rendering without being mounted - in order to properly debug this we'd need to see the actual code you're using to build this UI

commented

I'm not going to lie to you, I don't know how or why it happens, sometimes I reproduce the crash on the first try after opening minecraft and sometimes no matter how hard I try it doesn't happen

Build: https://github.com/Zailer43/FZMM-Mod/actions/runs/3257385285
Source: https://github.com/Zailer43/FZMM-Mod/tree/change_malilib_to_owo_lib
Screen: https://github.com/Zailer43/FZMM-Mod/blob/change_malilib_to_owo_lib/src/main/java/fzmm/zailer/me/client/gui/HeadGeneratorScreen.java

Reproduction steps:

  1. go to a world
  2. press "z" or the configured key to open the FZMM gui
  3. go to "Head generator"
  4. load a skin
    4.1. place the name of a premium player in the "skin" field
    4.2. click the "Load skin" button
    4.3. if an error occurred loading the skin go back to step 4.2, if it doesn't work verify that the user is premium
  5. wait a few seconds
  6. crash
  7. If I don't crash, click the button back to step 4.2 again, if it works after several attempts restart minecraft