Author Topic: BUG REPORT - Game freezes when using "smart hide objects"  (Read 678 times)

0 Members and 1 Guest are viewing this topic.

Offline Arxidamos

BUG REPORT - Game freezes when using "smart hide objects"
« on: October 03, 2017, 05:27:13 PM »
System specs
-> Intel Core i7 920 @ 2.67GHz
    12,0GB Triple-Channel DDR3 @ 534MHz
    2047MB NVIDIA GeForce GTX 660 (EVGA)
    MSI MSI X58 PLATINUM
    Realtek High Definition Audio
    111GB KINGSTON SVP200S37A120G ATA Device (SSD)
    Windows 7 64
    Other users have reported the game freezing. May be because of the same problem.

Simutrans version:
-> 120.2


Description
-> When using "smart hide objects", game freezes and never recovers. Then I have to close it.


How can this problem be reproduced?
-> When I play without "smart hide objects" it works fine. After I click this option,
   the game freezes after a few seconds.


Did you discover a workaround for the problem?
-> I found this on a forum.
   "There is now an option in Steam under betas for 'SDL_' this will load the SDL version of Simutrans
   on Windows. This may resolve issues for some users."
   The user reports it solved the problem but other problems occured.
   But I don't have and don't want a steam account.


Severity of the problem/urgency to fix it? (One of high, medium, low or a more detailed description)
-> High... For me at least...

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #1 on: October 03, 2017, 05:34:00 PM »
You don't need Steam to get the SDL version of Simutrans. That is available on simutrans.com right next to the GDI version.

Offline Leartin

Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #2 on: October 03, 2017, 05:36:20 PM »
You can use both GDI-Version and SDL-Version without steam.
https://www.simutrans.com/en/download/
Just don't get distracted by the large shiny "Download for Windows"-button, in the section "Other Platforms" you find both GDI and SDL Version for Windows. I'm not sure which version you are currently using, but since it seems graphics related, using the other one might fix the problem for you.

Offline Arxidamos

Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #3 on: October 03, 2017, 05:52:32 PM »
Well, I tried both GDI and SDL and still the same... It still freezes after a while. Without it everything seems to be working fine.

The only difference is that in the SDL version it takes longer before freezing. I don' t know if that means anything..
« Last Edit: October 03, 2017, 07:44:37 PM by Isaac.Eiland-Hall »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #4 on: October 03, 2017, 06:27:49 PM »
GDI/SDL are not really used for rendering the objects, so switching between them should not normally cure a freeze in the rendering to go away. On the other hand, I would not expect rendering to cause a freeze at all. Then again, there is some threading (of the bad upper-right quadrant type as I've been told) in there that might be enabled in the published builds.

Offline TurfIt

Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #5 on: October 04, 2017, 01:00:10 AM »
Not sure what bad upper-right quadrant type threading is.... Google gets me IBS and alcoholic liver disease results...  Continuing smart hide trouble does indeed make me irritable, although hopefully not at that end, and does drive one to drink too much!

Can duplicate if I select "too many" threads. Looking at the code, immediately obvious where the race condition is, WTF was I thinking doing that?? But, how did this survive for 4 years? sigh.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4280
  • Total likes: 196
  • Helpful: 149
  • Languages: EN, DE, AT
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #6 on: October 04, 2017, 05:23:58 AM »
I also observed strange behaviour with smart hiding: After enabled, the map was not drawn properly, lot of artefacts. I did not have time to look into this.
Parsley, sage, rosemary, and maggikraut.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #7 on: October 04, 2017, 05:55:29 AM »
Not sure what bad upper-right quadrant type threading is....

It is something I've heard about at developer conferences recently. I could not find a name for the entire diagram, which has one axis of mutability and one axis of concurrency (or was it sharing or something like that), but the upper-right quadrant is apparently sometimes called the synchronization quadrant. That is where all the bad things happen. (The speaker, Kevlin Henney, is quite funny to listen to, although he makes serious points that make you feel guilty. And his talks are not just about threading, although some of them might be.)

Offline Leartin

Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #8 on: October 04, 2017, 08:55:24 AM »
...I guess that would be his speech, for anyone interested.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #9 on: October 04, 2017, 04:38:06 PM »
He has many speeches (and at least one book), and some elements are recycled. The one I saw last (mid-September) and that was fresh in my mind was called something about immutability.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8830
  • Total likes: 324
  • Helpful: 229
  • Languages: De,EN,JP
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #10 on: October 05, 2017, 07:53:17 AM »
Can duplicate if I select "too many" threads. Looking at the code, immediately obvious where the race condition is, WTF was I thinking doing that?? But, how did this survive for 4 years? sigh.

May you enlight us with your findings ;)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4900
  • Total likes: 217
  • Helpful: 108
  • Languages: EN, NO
Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #11 on: October 05, 2017, 05:46:16 PM »
It is an interesting mix of fun and frustration when a bug reports ticks in, and the problem is not understanding why it fails, as that turns out to be obvious (in hindsight at least), but how anything could possibly have been working for years.

Offline TurfIt

Re: BUG REPORT - Game freezes when using "smart hide objects"
« Reply #12 on: October 05, 2017, 10:29:00 PM »
May you enlight us with your findings ;)
Wish I could. Must've been a fleeting thought or something as I have no idea what I was seeing.

However, discovered by accident replacing the cond_wait with a cond_timedwait doesn't freeze. (and the timer was never expiring). Bizarre. Or buggy pthread? or still buggy Simutrans? Don't know.
I did recently do a mingw upgrade which brought new versions of lots of libs incl. pthread, so am trusting nothing right now...

Also, changing the hiding_cond broadcast to before the mutex unlock also prevents the freeze. Also Bizarre. The broadcasting thread shouldn't need to be holding the condition mutex.

Perhaps someone else can try to replicate this?
For me, setting Simutrans to use 8 or 12 threads, on a 4 core / 8 thread CPU, and turning on the smart hide with radius 10 results in a freeze within 10 secs of mouse jiggling 95% of the time, and shortly thereafter for the rest. Making either of the changes above and no freeze for minutes at least.


I also observed strange behaviour with smart hiding: After enabled, the map was not drawn properly, lot of artefacts. I did not have time to look into this.
Can you expand on this? I'm not seeing any issues here after the marking dirty fixes from ~18 months ago.

It is strange how trees are completely hidden around the mouse cursor, unless you have them already set to transparent, then the transparent trees remain... Perhaps that how those who actually use this feature want it?