Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [0.95.1a-RC6] SlipstreamManager hang?  (Read 1227 times)

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
[0.95.1a-RC6] SlipstreamManager hang?
« on: December 29, 2021, 07:58:33 AM »

A number of people (two that I know of) on Discord have been reporting hangs in the middle of play. Both posted VisualVM thread dumps, which contained the following:

"Thread-3" #18 prio=5 os_prio=0 tid=0x0000021a8f187800 nid=0x33bc runnable [0x00000086589fe000]
   java.lang.Thread.State: RUNNABLE
        at com.fs.starfarer.api.util.CollisionGridUtil.addObject(CollisionGridUtil.java:81)
        at com.fs.starfarer.api.impl.campaign.velfield.SlipstreamManager.updateGrid(SlipstreamManager.java:837)
        at com.fs.starfarer.api.impl.campaign.velfield.SlipstreamManager.checkIntersection sAndFadeSections(SlipstreamManager.java:628)
        at com.fs.starfarer.api.impl.campaign.velfield.SlipstreamManager.addStream(SlipstreamManager.java:607)
        at com.fs.starfarer.api.impl.campaign.velfield.SlipstreamManager.advance(SlipstreamManager.java:513)
        at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
        at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
        at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
        at com.fs.state.AppDriver.begin(Unknown Source)
        at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
        at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
        at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:748)

My eyeballing of the code involved has failed to notice any way this could even happen, and I need to go to bed, so I'll just leave this here for now.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #1 on: December 29, 2021, 09:35:39 AM »

Hmm, very strange. About the only thing I can imagine is if somehow a jump-point ended up with "Infinity" coordinates or radius - then CollisionGridUtil.addObject() seems like it could spend a long time in that for loop - not strictly an infinite loop, but a pair of nested for loops going through the full set of integer values could definitely feel like a total hang.
Logged

Bunkeror

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #2 on: December 29, 2021, 01:40:27 PM »

I am one of the people for which this happens

Is there anything I can do to help try and pinpoint the issue?

It doesn't only happen in hyperspace, it also freezes if you're in a system

So far only killing slipstreams has worked
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #3 on: December 29, 2021, 02:21:56 PM »

Thank you! Hmm - which mods are you running with? And is the hang easily reproducible from a save you have? If the mod list isn't too large I could try loading your save on my end to see what's going on.
Logged

Bunkeror

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #4 on: December 29, 2021, 04:20:28 PM »

Alright- here it is

I assume people use way more mods than I do

Upon save load, everything is pretty slow, after some minutes at most, pretty much wherever you are, the game will freeze

Music and sounds will still go on, though

Is this enough?

https://easyupload.io/dzci9c
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #5 on: December 29, 2021, 05:45:56 PM »

Thank you so much! Having the mods folder is really handy.

So, it looks like the hang is caused by a jump-point in hyperspace, with coordinates:
(org.lwjgl.util.vector.Vector2f) Vector2f[3.4028235E38, 3.4028235E38]

This leads to CollisionGridUtil.addObject() ending up with Integer.MAX_VALUE for start/end X/Y, there's an overflow when the loop variable is incremented, and it becomes an infinite loop.

The jump-point has an exit into "the Apsu star system".
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #6 on: December 29, 2021, 06:24:01 PM »

Apsu is in the vanilla name gen data, but if I'm reading this right it can only be used as a name for a secondary star.

In any case, might be good to search in the mod folder to see if any mods add a manually created system with that name (perhaps with the intent of hiding it).
Otherwise, it could be a bug with Adjusted Sector or a particular configuration for the mod, if it's in use?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #7 on: December 29, 2021, 06:31:24 PM »

(In the meantime: added a failsafe here for the future...)

It seems like whatever moved this jump-point did this after the previous time a slipstream was created, or it would've hung there - so it's likely some dynamic code going off the rails, and probably not something that happened during sector creation. Unless, I suppose, a jump-point accidentally got a velocity and just drifted like a ticking timebomb - though if that were the case, I'd have expected its coordinates to be less neat and tidy.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #8 on: December 29, 2021, 06:37:00 PM »

I'm not sure it is neat and tidy, isn't that max value? If it was moving in any +/+ direction, it'd eventually end up there.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #9 on: December 29, 2021, 06:40:18 PM »

Yeah, but since either one of the coordinates getting there (or even close to there) would be enough to cause the hang... I suppose it's possible, just depends on how long it had, and what the velocity was, assuming that's even how it happened.
Logged

Bunkeror

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #10 on: December 29, 2021, 06:52:13 PM »

Riiiiiiight! So after all the smart people talk-

... Is there anything I can do, other than the hotfix of killing slipstreams every save load lol
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #11 on: December 29, 2021, 06:55:03 PM »

Hmm - you could do some savefile surgery by looking for "3.4028235E38" (without the quotes). That should lead you to a jump-point's data in the file, and there should be two of those in the file. Changing them, to, like 0 might get around the issue, provided it's the only jump-point with the problem, but depending on what caused this to happen in the first place, it might re-manifest, perhaps immediately.
Logged

legenbone

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: [0.95.1a-RC6] SlipstreamManager hang?
« Reply #12 on: December 30, 2021, 09:42:26 AM »

Hey all! This is Legenbone - I am one of the two people that reported this bug to Histidine. I guess I found the culprit - Beyond the Sector mod. It lets you go through a gate to a system faraway, and the screenshot is attached.
Logged