Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: TooltipMakerAPI.showCargo() freezes game when used on modified CargoAPI  (Read 676 times)

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile

This is a very odd behaviour, but once again it might be me doing something wrong. Please don't spend too much time on it as I have a workaround ready.

I display cargo content using showCargo, cargo that is passed comes directly from submarketAPI.getCargo(). The intel also has a button that when clicked displays show interaction dialog (ui.showDialog). Interaction dialog has nothing in it, just calls showCargoPickerDialog and handles cargo transfer (from player to submarket).
 
All is fine if I initially display intel (intel screen), and once again is fine after clicking button and picking cargo from storage (intel is updated via ui.updateUIForItem after successful handler for picker terminates). But on the second button press, after transferring cargo again, ui.updateUIForItem hangs, specifically call to showCargo just hangs.

So far I have fixed this by creating a copy of cargo instead of using submarket's getCargo() directly. Which leads me to thinking that perhaps (since no time has passed game-wise between those cargo updates), the submarkets cargo is somehow dirty, and I avoid the problem with it (either in cargo or in showCargo) by creating a new object.
« Last Edit: October 15, 2020, 01:33:44 PM by Jaghaimo »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: TooltipMakerAPI.showCargo() freezes game when used on modified CargoAPI
« Reply #1 on: October 15, 2020, 01:37:28 PM »

Hmm this sounds like it could be a bug, yeah. Honestly, I'm not sure I'll be able to make heads or tails of this without an easy-to-reproduce example. If you're able to work around it, though...
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: TooltipMakerAPI.showCargo() freezes game when used on modified CargoAPI
« Reply #2 on: October 16, 2020, 03:59:51 AM »

Here is the code to reproduce: https://github.com/jaghaimo/showCargo-bug/blob/master/src/main/jaghaimo/Bug.java
Repository is self-contained and ripe for cloning and building: https://github.com/jaghaimo/showCargo-bug
Or just use the build provided: https://github.com/jaghaimo/showCargo-bug/releases/tag/bug

Reproduction steps:
  • Click button
  • get an item
  • confirm
  • experience a freeze (infinite loop?)
Workaround:
  • Use line with cargo.createCopy() instead
  • everything works
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: TooltipMakerAPI.showCargo() freezes game when used on modified CargoAPI
« Reply #3 on: October 16, 2020, 08:48:05 AM »

Thank you! I really appreciate how easy you've made this for me.

Fixed for the next release!

(The issue was that the cargo being shown ended up with a zero-size stack in it, which caused an issue for the code that was indenting the stack counts, since it was using log(stackSize) to figure out how much to indent those. Which was returning -Infinity (learned something new today), and that was used in a loop, and, well.)
Logged