[Rejected] Fix for not disabling Imon display sometimes (1 Viewer)

Waly

MP Donator
  • Premium Supporter
  • July 21, 2009
    18
    3
    Home Country
    Czech Republic Czech Republic
    Hello,


    I had occasionally from start of using MP problem with not disabling Imon display when going to hibernate mode. After adding some plugin (its not important which) situation got worse. I looked around a little bit and I found, that in log is this line (only when display is not disabled):

    Code:
    [Info.][MiniDisplay(12)]: MiniDisplay.Run(): CAUGHT ThreadAbortException

    That probably means, that imon driver have not enough time to disable display sometimes, because is thread aborted by MiniDisplay.


    I tried to increase timeout before aborting thread to 15 seconds (was 5 seconds) and now it seems to be working very well.

    I prepared two version of patch. One is simpliest, because it changes timeout globally for all DoStop calls. Second (individual) changes this timeout only for PowerModes.Suspend case.

    Both patches are for r26757 in trunk.

    UPDATE:
    I prepared second version of patch - now a little bit more complex
    Minidisplay:
    - improved work with background thread (stopping)
    iMONLCD:
    - support of newest iMON drivers 7.91.0929 (old drivers <7.80 will be probably not working)
    - improved initialization routine according to newest drivers
    - improved work with background thread (stopping)
    - some other fixes

    I tested it for several hours and it seems it is working ok. I hope that any compatibility with other displays was not touched (this was my target).
     

    Attachments

    • iMonLCD_r26815_V2.patch
      70.2 KB
    • MiniDisplay_r26815_V2.patch
      6.4 KB

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for not disabling Imon display sometimes

    have the same problem and will try your 2nd patch
     

    Waly

    MP Donator
  • Premium Supporter
  • July 21, 2009
    18
    3
    Home Country
    Czech Republic Czech Republic
    Early happiness probably, now I had again one case of not disabled display. But good too see anyone with same problem.

    I also catched some log before:

    correctly disabled:
    Code:
     21:01:43.369131 [Info.][MPMain(1)]: Main: WM_POWERBROADCAST: 4
     21:01:43.369131 [Info.][MPMain(1)]: Main: Windows is suspending
     21:01:43.371131 [Info.][MPMain(1)]: Main: Stopping playback
     21:01:43.372131 [Debug][MPMain(1)]: Main: SaveLastActiveModule - enabled False
     21:01:43.375131 [Info.][MPMain(1)]: Main: Stopping AutoPlay
     21:01:43.378131 [Info.][MPMain(1)]: open folderdatabase
     21:01:43.382131 [Info.][MPMain(1)]: picture database opened
     21:01:43.386131 [Info.][MPMain(1)]: Main: OnSuspend - Done
     21:01:43.444133 [Info.][.NET SystemEvents(4)]: MiniDisplay: Suspend or Hibernation detected, shutting down plugin
     21:01:43.445133 [Info.][.NET SystemEvents(4)]: MiniDisplay.DoStop(): Called.
     21:01:43.446133 [Info.][.NET SystemEvents(4)]: MiniDisplay.DoStop(): Requesting background thread to stop.
     21:01:43.597137 [Info.][MiniDisplay(10)]: MiniDisplay.DisplayHandler.Stop(): Called
     21:01:43.597137 [Info.][MiniDisplay(10)]: MiniDisplay.DisplayHandler.Stop(): Calling driver CleanUp() function
     21:01:43.598137 [Info.][MiniDisplay(10)]: (IDisplay) iMONLCDg.CleanUp(): called
     21:01:43.601137 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): called
     21:01:43.601137 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): Stopping iMONLCDg.UpdateIcons() Thread
     21:01:43.697140 [Info.][UpdateIconThread(3)]: iMONLCDg.UpdateIcons(): Icon Update Thread terminating
     21:01:44.101151 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): Preparing for shutdown
     21:01:44.105151 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): sending display shutdown command to LCD2
     21:01:44.658166 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): Removing Power State Monitor callback from system event thread
     21:01:44.660166 [Info.][MiniDisplay(10)]: iMONLCDg.CloseLcd(): completed
     21:01:44.660166 [Info.][MiniDisplay(10)]: (IDisplay) iMONLCDg.CleanUp(): completed
     21:01:44.660166 [Info.][MiniDisplay(10)]: MiniDisplay.DisplayHandler.Stop(): completed
     21:01:44.746168 [Debug][.NET SystemEvents(4)]: iMONLCDg.SystemEvents_PowerModeChanged: SystemPowerModeChanged event was raised.
     21:01:44.746168 [Info.][.NET SystemEvents(4)]: iMONLCDg.SystemEvents_PowerModeChanged: Suspend or Hibernation detected, shutting down display
     21:01:44.747168 [Info.][.NET SystemEvents(4)]: iMONLCDg.CloseLcd(): called
     21:01:44.747168 [Info.][.NET SystemEvents(4)]: iMONLCDg.CloseLcd(): Preparing for shutdown
     21:01:44.751168 [Info.][.NET SystemEvents(4)]: iMONLCDg.CloseLcd(): sending display shutdown command to LCD2
     21:01:44.753168 [Info.][.NET SystemEvents(4)]: iMONLCDg.CloseLcd(): completed


    and not disabled only this:

    Code:
     19:09:19.950401 [Info.][MPMain(1)]: Main: WM_POWERBROADCAST: 4
     19:09:19.950401 [Info.][MPMain(1)]: Main: Windows is suspending
     19:09:19.950401 [Info.][MPMain(1)]: Main: Stopping playback
     19:09:19.951401 [Debug][MPMain(1)]: Main: SaveLastActiveModule - enabled False
     19:09:19.951401 [Info.][MPMain(1)]: Main: Stopping AutoPlay
     19:09:19.951401 [Info.][MPMain(1)]: Main: OnSuspend - Done
     19:09:22.593473 [Debug][GenericPCQueue(6)]: MPBlastZonePlugin: Received Message "RemoteEvent"
     19:09:22.593473 [Debug][GenericPCQueue(8)]: MPControlPlugin: Received Message "RemoteEvent"



    It seems that imon driver doesn't receive SystemEvents_PowerModeChanged event. But I have no idea why...
     

    1stdead

    Portal Pro
    February 1, 2008
    1,089
    139
    Copenhagen
    Home Country
    Denmark Denmark
    I can confirm this behavior. I talked with chemelli about it and figured out that was because MP/plugins have high load, so that the abort isn't initiated.. Great this might work.
     

    Waly

    MP Donator
  • Premium Supporter
  • July 21, 2009
    18
    3
    Home Country
    Czech Republic Czech Republic
    I have found, that to complete reliable solution some few parts of iMONLCDg drivers must be overwritten. For example when stopping _iconThread thread, there are several Thread.Sleeps, that are blocking to really stop iconThread quickly. Instead of sleeps there should be used some event such as AutoResetEvent and WaitOne with TimeSpan. And in master thread after firing event should be use Thread.Join. No sleeps are necessary. I mean I can fix it, but would like be sure, that my patch will be really used and not thrown to trash...
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    I mean I can fix it, but would like be sure, that my patch will be really used and not thrown to trash...
    As long as the code meets the standards and does not break anything there is a good chance it will get included into code base.

    Final say will go to MP Dev team managers but this sounds like you know what you are doing
     

    Waly

    MP Donator
  • Premium Supporter
  • July 21, 2009
    18
    3
    Home Country
    Czech Republic Czech Republic
    I am here again with updated version in first post. Here are some changes:

    UPDATE:
    I prepared second version of patch - now a little bit more complex
    Minidisplay:
    - improved work with background thread (stopping)
    iMONLCD:
    - support of newest iMON drivers 7.91.0929 (old drivers <7.80 will be probably not working)
    - improved initialization routine according to newest drivers
    - improved work with background thread (stopping)
    - some other fixes

    I tested it for several hours and it seems it is working ok. I hope that any compatibility with other displays was not touched (this was my target).
     

    chemelli

    Retired Team Member
  • Premium Supporter
  • September 28, 2006
    6,159
    2,264
    49
    Milano, Italy
    Home Country
    Italy Italy
    I am here again with updated version in first post. Here are some changes:

    UPDATE:
    I prepared second version of patch - now a little bit more complex
    Minidisplay:
    - improved work with background thread (stopping)
    iMONLCD:
    - support of newest iMON drivers 7.91.0929 (old drivers <7.80 will be probably not working)
    - improved initialization routine according to newest drivers
    - improved work with background thread (stopping)
    - some other fixes

    I tested it for several hours and it seems it is working ok. I hope that any compatibility with other displays was not touched (this was my target).

    I would spend the time on reworking code to support the new Display API from SG ;)

    Simone
     

    Waly

    MP Donator
  • Premium Supporter
  • July 21, 2009
    18
    3
    Home Country
    Czech Republic Czech Republic
    I mean that new API is not currently very good, too much missing features :-/ And SG probably will not give time for any improvements, its for them not much important thing...
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for not disabling Imon display sometimes

    chemelli
    wouldn't it be better to integrate that stuff than waiting for SG API or improbements on their side... as you know they're slow and mostly don't care about such stuff.
     

    Users who are viewing this thread

    Top Bottom