The International Simutrans Forum

 

Author Topic: Black screen flicker in Windows GDI  (Read 2364 times)

0 Members and 1 Guest are viewing this topic.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Black screen flicker in Windows GDI
« on: September 04, 2013, 05:14:46 PM »
Today I was playing and under heavy CPU pressure, the screen flickered black some times when in fast forward, I don't know exacly what causes this, but it might be related to threading. Or not.

Sometimes the screen turned black and it was slowly redrawn correctly **on dirty tiles only**, the rest of screen remained black.

I use Win32, Built with VS2012, GDI. MULTI_THREAD=4

@6670

I'm the only one that noticed this?

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1327
Re: Black screen flicker in Windows GDI
« Reply #1 on: September 04, 2013, 05:23:39 PM »
I've noticed lately something changing the zoom level when the CPU gets too busy. ie. try to raise a huge mountain, the program goes unresponsive, then when it comes back it auto zooms in, but doesn't mark the whole screen dirty. Hence moving objects get drawn in the new zoom on top of the old size terrain. Whereever this auto zoom has come from, it has gotta go...

I've not seen a flickering black screen, but I usually use SDL.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Black screen flicker in Windows GDI
« Reply #2 on: September 04, 2013, 05:35:30 PM »
I compiled the single thread version and the problem disapeared. Might be a race condition, somehow the screen in flushed black (in simview.cc, line 153), and written entirely to screen before it's redrawn.

EDIT: No, it can't be because the screen whould be GRAY, not black. Maybe Win32 losed the framebuffer and hinted us to refill screen completely and we ignored the event. Or maybe it's a bug in my video card driver. Only showed in high CPU usage, the sound was even pausing, si it might have been just my system.

 But if someone has similar problems, report them, please. :)

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1327
Re: Black screen flicker in Windows GDI
« Reply #3 on: September 04, 2013, 05:43:47 PM »
Try multithreaded, but with the multithreading in simsys_w.cc disabled. ( I just search/replace in _w.cc for MULTI_THREAD -> mMULTI_THREAD) That would isolate the threaded simview from the OS stuff.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4608
  • Languages: EN, DE, AT
Re: Black screen flicker in Windows GDI
« Reply #4 on: September 04, 2013, 06:44:15 PM »
I've noticed lately something changing the zoom level when the CPU gets too busy. ie. try to raise a huge mountain, the program goes unresponsive, then when it comes back it auto zooms in, but doesn't mark the whole screen dirty. Hence moving objects get drawn in the new zoom on top of the old size terrain. Whereever this auto zoom has come from, it has gotta go...
Could reproduce this, the call is in karte_t::update_frame_sleep_time... it should set everything dirty..

Edit: try r6680.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1327
Re: Black screen flicker in Windows GDI
« Reply #5 on: September 04, 2013, 08:17:00 PM »
That fixes the dirty, but doesn't fix the fact it should never have changed the zoom in the first place. I assume the intent is to maintain some responsiveness if the user zooms out too far for their computer to handle. But if the hiccup is due to a user initiated command that takes a while, zooming in is annoying and accomplishes nothing.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9595
  • Languages: De,EN,JP
Re: Black screen flicker in Windows GDI
« Reply #6 on: September 05, 2013, 11:47:34 AM »
Which command should this be (apart from raising a 14+ hill)? You need to be without response for a long time.

95% of the errors of getting inresponsitive is zooming out too much. And then you cannot even save your game anymore. Hence this emergency measure which is better than loosing the game.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1327
Re: Black screen flicker in Windows GDI
« Reply #7 on: September 05, 2013, 08:31:07 PM »
I thought I'd seen it on repeatedly rotating a huge map, but I can't replicate it now. Doing that does kill the framerate for ~30 secs until it recovers, but that's an entirely separate problem.