Mailing List Archive

mythfrontend on ubuntu 17.04 testing X11 ICE problems
I appear to have lost outgoing SMTP mail. On the plus side. I think I may found the answer.

----- Original Message -----
From: roger roger@beardandsandals.co.uk
To: Mythtv Developers mythtv-dev@mythtv.org
Sent: Sat 4/02/17 8:02 PM
Subject: Fwd: Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems


On 04/02/17 16:27, roger wrote:
>
>
> On 04/02/17 15:30, roger wrote:
>> I have set up my little Shuttle XS35V3 box as an ubuntu 17.04
>> testbed. I have built and and installed from the 2.8 fixes branch.
>>
>> I keep getting this from mythfrontend on stderr
>>
>> ICE default IO error handler doing an exit(), pid = 1752, errno = 32
>> QWaitCondition: cv destroy failure: Device or resource busy
>> QWaitCondition: mutex destroy failure: Device or resource busy
>>
>> The old trick of deleting the ..ICEauthority file seems to work if
>> you do it right after mythfrontend exits, this may be a red herring.
>> But unfortunately the error will reappear at some point, most likely
>> on the next boot.
>>
>> This problem seems to have been around for ages.
>>
>> Does anyone know what Qt is doing with ICE?
>>
>> Errno 32 is broken pipe. So what is dying and why?
>>
>> Seeing as I have hijacked the families myth box for testing, I am
>> keen to fix this :-).
>>
>> So all help will be gratefully received.
>>
>>
>> Roger
>>
>
> Sorry about the dual posting, the first one did not appear for until I
> posted the second.
>
> The top and bottom of this is that something appears to be killing the
> connection between mythfrontend and the X session manager. On the my
> setup the session manager is xfce4_sm. I have set XFSM_VERBOSE and
> have found something interesting.
>
> My backend is configured for idle shutdown and wake on lan. The
> backend system runs the database server as well. If the backend system
> is not running then then mythfrontend goes into it wake on lan
> procedure. At some time in the distant past this started to prevent
> the gui from appearing, although I am not entirely sure about this, it
> might have always done it. This is what the session manager log shows
> happening.
>
> TRACE[xfsm-manager.c:1295] xfsm_manager_save_yourself_done():
> enteringTRACE[sm-layer.c:162] sm_new_client(): ICE connection fd = 20,
> received NEW CLIENT
>
> TRACE[sm-layer.c:213] sm_register_client(): ICE connection fd = 20,
> received REGISTER CLIENT [Previous Id = None]
>
> TRACE[xfsm-manager.c:1607] xfsm_manager_save_timeout(): Client id =
> 2ac51c2aa-c28b-4b54-8412-69aec21ced14, received SAVE TIMEOUT
> Client will be disconnected now.
>
> This happens whilst the frontend is still waiting for the database
> connection to come up. When it does the frontend does a whole load of
> gui image loads the thing you see in the log in loading
> watermark/dvd.png at which point the ICE error occurs, presumably when
> the main loop tries to send something to the session manager.
>
> Roger
>
Ok I can see what is happening now MSqlDatabase::OpenDatabase in
mythdbcon.cpp has a sleep in the wake on lan loop. This is very
unfriendly in a gui environment as the main message loop does not get
actioned.

Possible fixes.

1. Write a gui friendly version of OpenDatabase.

2. Move the wol stuff up into mythfrontend (I wonder if this was already
done in reverse in the past/).

3. Do it in a wrapper.

4. Do it in systemd.

5. ?

Roger



_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
I have set up my little Shuttle XS35V3 box as an ubuntu 17.04 testbed. I
have built and and installed from the 2.8 fixes branch.

I keep getting this from mythfrontend on stderr

ICE default IO error handler doing an exit(), pid = 1752, errno = 32
QWaitCondition: cv destroy failure: Device or resource busy
QWaitCondition: mutex destroy failure: Device or resource busy

The old trick of deleting the ..ICEauthority file seems to work if you
do it right after mythfrontend exits, this may be a red herring. But
unfortunately the error will reappear at some point, most likely on the
next boot.

This problem seems to have been around for ages.

Does anyone know what Qt is doing with ICE?

Errno 32 is broken pipe. So what is dying and why?

Seeing as I have hijacked the families myth box for testing, I am keen
to fix this :-).

So all help will be gratefully received.


Roger

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 04/02/17 15:30, roger wrote:
> I have set up my little Shuttle XS35V3 box as an ubuntu 17.04 testbed.
> I have built and and installed from the 2.8 fixes branch.
>
> I keep getting this from mythfrontend on stderr
>
> ICE default IO error handler doing an exit(), pid = 1752, errno = 32
> QWaitCondition: cv destroy failure: Device or resource busy
> QWaitCondition: mutex destroy failure: Device or resource busy
>
> The old trick of deleting the ..ICEauthority file seems to work if you
> do it right after mythfrontend exits, this may be a red herring. But
> unfortunately the error will reappear at some point, most likely on
> the next boot.
>
> This problem seems to have been around for ages.
>
> Does anyone know what Qt is doing with ICE?
>
> Errno 32 is broken pipe. So what is dying and why?
>
> Seeing as I have hijacked the families myth box for testing, I am keen
> to fix this :-).
>
> So all help will be gratefully received.
>
>
> Roger
>

Sorry about the dual posting, the first one did not appear for until I
posted the second.

The top and bottom of this is that something appears to be killing the
connection between mythfrontend and the X session manager. On the my
setup the session manager is xfce4_sm. I have set XFSM_VERBOSE and have
found something interesting.

My backend is configured for idle shutdown and wake on lan. The backend
system runs the database server as well. If the backend system is not
running then then mythfrontend goes into it wake on lan procedure. At
some time in the distant past this started to prevent the gui from
appearing, although I am not entirely sure about this, it might have
always done it. This is what the session manager log shows happening.

TRACE[xfsm-manager.c:1295] xfsm_manager_save_yourself_done():
enteringTRACE[sm-layer.c:162] sm_new_client(): ICE connection fd = 20,
received NEW CLIENT

TRACE[sm-layer.c:213] sm_register_client(): ICE connection fd = 20,
received REGISTER CLIENT [Previous Id = None]

TRACE[xfsm-manager.c:1607] xfsm_manager_save_timeout(): Client id =
2ac51c2aa-c28b-4b54-8412-69aec21ced14, received SAVE TIMEOUT
Client will be disconnected now.

This happens whilst the frontend is still waiting for the database
connection to come up. When it does the frontend does a whole load of
gui image loads the thing you see in the log in loading
watermark/dvd.png at which point the ICE error occurs, presumably when
the main loop tries to send something to the session manager.

Roger

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 02/05/2017 05:33 AM, roger@beardandsandals.co.uk wrote:
> I appear to have lost outgoing SMTP mail. On the plus side. I think I may found the answer.
>
> ----- Original Message -----
> From: roger roger@beardandsandals.co.uk
> To: Mythtv Developers mythtv-dev@mythtv.org
> Sent: Sat 4/02/17 8:02 PM
> Subject: Fwd: Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems
>
>
> On 04/02/17 16:27, roger wrote:
>>
>> On 04/02/17 15:30, roger wrote:
>>> I have set up my little Shuttle XS35V3 box as an ubuntu 17.04
>>> testbed. I have built and and installed from the 2.8 fixes branch.
>>>
>>> I keep getting this from mythfrontend on stderr
>>>
>>> ICE default IO error handler doing an exit(), pid = 1752, errno = 32
>>> QWaitCondition: cv destroy failure: Device or resource busy
>>> QWaitCondition: mutex destroy failure: Device or resource busy
>>>
>>> The old trick of deleting the ..ICEauthority file seems to work if
>>> you do it right after mythfrontend exits, this may be a red herring.
>>> But unfortunately the error will reappear at some point, most likely
>>> on the next boot.
>>>
>>> This problem seems to have been around for ages.
>>>
>>> Does anyone know what Qt is doing with ICE?
>>>
>>> Errno 32 is broken pipe. So what is dying and why?
>>>
>>> Seeing as I have hijacked the families myth box for testing, I am
>>> keen to fix this :-).
>>>
>>> So all help will be gratefully received.
>>>
>>>
>>> Roger
>>>
>> Sorry about the dual posting, the first one did not appear for until I
>> posted the second.
>>
>> The top and bottom of this is that something appears to be killing the
>> connection between mythfrontend and the X session manager. On the my
>> setup the session manager is xfce4_sm. I have set XFSM_VERBOSE and
>> have found something interesting.
>>
>> My backend is configured for idle shutdown and wake on lan. The
>> backend system runs the database server as well. If the backend system
>> is not running then then mythfrontend goes into it wake on lan
>> procedure. At some time in the distant past this started to prevent
>> the gui from appearing, although I am not entirely sure about this, it
>> might have always done it. This is what the session manager log shows
>> happening.
>>
>> TRACE[xfsm-manager.c:1295] xfsm_manager_save_yourself_done():
>> enteringTRACE[sm-layer.c:162] sm_new_client(): ICE connection fd = 20,
>> received NEW CLIENT
>>
>> TRACE[sm-layer.c:213] sm_register_client(): ICE connection fd = 20,
>> received REGISTER CLIENT [Previous Id = None]
>>
>> TRACE[xfsm-manager.c:1607] xfsm_manager_save_timeout(): Client id =
>> 2ac51c2aa-c28b-4b54-8412-69aec21ced14, received SAVE TIMEOUT
>> Client will be disconnected now.
>>
>> This happens whilst the frontend is still waiting for the database
>> connection to come up. When it does the frontend does a whole load of
>> gui image loads the thing you see in the log in loading
>> watermark/dvd.png at which point the ICE error occurs, presumably when
>> the main loop tries to send something to the session manager.
>>
>> Roger
>>
> Ok I can see what is happening now MSqlDatabase::OpenDatabase in
> mythdbcon.cpp has a sleep in the wake on lan loop. This is very
> unfriendly in a gui environment as the main message loop does not get
> actioned.
>
> Possible fixes.
>
> 1. Write a gui friendly version of OpenDatabase.
>
> 2. Move the wol stuff up into mythfrontend (I wonder if this was already
> done in reverse in the past/).
>
> 3. Do it in a wrapper.
>
> 4. Do it in systemd.
>
> 5. ?
>
> Roger
>
>
>
I have just committed new code that greatly improves the experience for
when the database or backend is down during frontend startup. This is in
Master, planned for MythTV version 29. There is nothing there as yet to
address the problem of the database or backend going down after GUI startup.

Peter

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 5 February 2017 3:46:37 pm Peter Bennett <pgbennett@comcast.net> wrote:

> I have just committed new code that greatly improves the experience for
> when the database or backend is down during frontend startup. This is in
> Master, planned for MythTV version 29. There is nothing there as yet to
> address the problem of the database or backend going down after GUI startup.
>
> Peter
>

Just had a quick look at the commit. It looks great.

I still think we need to address issues about front-end startup failing
without leaving any evidence in the log with default settings. By this I
mean the "it just wouldn't load and the log just stops with no error
messages" type of error.

The fault I was originally describing was one of these. It was caused by
the default error handler in libice just writing some things to stderr and
calling exit. The use of libice is buried deep in Qt so that problem may
have to be addressed as a Qt bug. There may be other cases, they are a pain
to find when the front-end is run in an environment where stderr is lost,
like that found in most automatic start up mechanisms. A belt and braces
approach may be to loop stderr into the log by default.

Another issue is our use of process exit codes that overlap reserved codes
when the front-end is run from a shell script. For example SIGSEGV being
misinterpreted as GENERIC_EXIT_INVALID_TIME.

Roger




_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 05/02/17 10:33, roger@beardandsandals.co.uk wrote:
>
> I appear to have lost outgoing SMTP mail. On the plus side. I think I may found the answer.
>
> ----- Original Message -----
> From: roger roger@beardandsandals.co.uk
> To: Mythtv Developers mythtv-dev@mythtv.org
> Sent: Sat 4/02/17 8:02 PM
> Subject: Fwd: Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems
>
>
> On 04/02/17 16:27, roger wrote:
>>
>>
>> On 04/02/17 15:30, roger wrote:
>>> I have set up my little Shuttle XS35V3 box as an ubuntu 17.04
>>> testbed. I have built and and installed from the 2.8 fixes branch.
>>>
>>> I keep getting this from mythfrontend on stderr
>>>
>>> ICE default IO error handler doing an exit(), pid = 1752, errno = 32
>>> QWaitCondition: cv destroy failure: Device or resource busy
>>> QWaitCondition: mutex destroy failure: Device or resource busy
>>>
>>> The old trick of deleting the ..ICEauthority file seems to work if
>>> you do it right after mythfrontend exits, this may be a red herring.
>>> But unfortunately the error will reappear at some point, most likely
>>> on the next boot.
>>>
>>> This problem seems to have been around for ages.
>>>
>>> Does anyone know what Qt is doing with ICE?
>>>
>>> Errno 32 is broken pipe. So what is dying and why?
>>>
>>> Seeing as I have hijacked the families myth box for testing, I am
>>> keen to fix this :-).
>>>
>>> So all help will be gratefully received.
>>>
>>>
>>> Roger
>>>
>>
>> Sorry about the dual posting, the first one did not appear for until I
>> posted the second.
>>
>> The top and bottom of this is that something appears to be killing the
>> connection between mythfrontend and the X session manager. On the my
>> setup the session manager is xfce4_sm. I have set XFSM_VERBOSE and
>> have found something interesting.
>>
>> My backend is configured for idle shutdown and wake on lan. The
>> backend system runs the database server as well. If the backend system
>> is not running then then mythfrontend goes into it wake on lan
>> procedure. At some time in the distant past this started to prevent
>> the gui from appearing, although I am not entirely sure about this, it
>> might have always done it. This is what the session manager log shows
>> happening.
>>
>> TRACE[xfsm-manager.c:1295] xfsm_manager_save_yourself_done():
>> enteringTRACE[sm-layer.c:162] sm_new_client(): ICE connection fd = 20,
>> received NEW CLIENT
>>
>> TRACE[sm-layer.c:213] sm_register_client(): ICE connection fd = 20,
>> received REGISTER CLIENT [Previous Id = None]
>>
>> TRACE[xfsm-manager.c:1607] xfsm_manager_save_timeout(): Client id =
>> 2ac51c2aa-c28b-4b54-8412-69aec21ced14, received SAVE TIMEOUT
>> Client will be disconnected now.
>>
>> This happens whilst the frontend is still waiting for the database
>> connection to come up. When it does the frontend does a whole load of
>> gui image loads the thing you see in the log in loading
>> watermark/dvd.png at which point the ICE error occurs, presumably when
>> the main loop tries to send something to the session manager.
>>
>> Roger
>>
> Ok I can see what is happening now MSqlDatabase::OpenDatabase in
> mythdbcon.cpp has a sleep in the wake on lan loop. This is very
> unfriendly in a gui environment as the main message loop does not get
> actioned.
>
> Possible fixes.
>
> 1. Write a gui friendly version of OpenDatabase.

We definitely should do this.

>
> 2. Move the wol stuff up into mythfrontend (I wonder if this was already
> done in reverse in the past/).
>
> 3. Do it in a wrapper.
>
> 4. Do it in systemd.
>

Not everyone uses systemd.

> 5. ?
>

Profit $$$ of course ;-)


Regards
Stuart


> Roger
>
>
>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-dev
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
>

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 6 February 2017 11:42:42 am Stuart Auchterlonie
<stuarta@squashedfrog.net> wrote:

>> 1. Write a gui friendly version of OpenDatabase.
>
> We definitely should do this.
>

Looks like Paul has already done it ????

>>
>> 2. Move the wol stuff up into mythfrontend (I wonder if this was already
>> done in reverse in the past/).
>>
>> 3. Do it in a wrapper.
>>
>> 4. Do it in systemd.
>>
>
> Not everyone uses systemd.
>
>> 5. ?
>>
>
> Profit $$$ of course ;-)
>

I see you spotted my riff on cheesy sales motivation presentations.

Cheers

Roger


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 06/02/17 19:44, Roger James wrote:
> On 6 February 2017 11:42:42 am Stuart Auchterlonie
> <stuarta@squashedfrog.net> wrote:
>
>>> 1. Write a gui friendly version of OpenDatabase.
>>
>> We definitely should do this.
>>
>
> Looks like Paul has already done it ????
>
>>>
>>> 2. Move the wol stuff up into mythfrontend (I wonder if this was already
>>> done in reverse in the past/).
>>>
>>> 3. Do it in a wrapper.
>>>
>>> 4. Do it in systemd.
>>>
>>
>> Not everyone uses systemd.
>>
>>> 5. ?
>>>
>>
>> Profit $$$ of course ;-)
>>
>
> I see you spotted my riff on cheesy sales motivation presentations.
>

Hah, I thought it was the Underpants Gnomes from South Park :)

Regards
Stuart


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 07/02/17 10:50, Stuart Auchterlonie wrote:
>
> Hah, I thought it was the Underpants Gnomes from South Park :)
>
> Regards
> Stuart
>
>
>
LOL

I had forgotten about that one. What was it...

1. Find underpants
2. ?
3. Profit

Or something.

R.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
Here is a suggested patch against mythdbcon.cpp in 2.8-fixes. It could used
at other places where sleep or other blocking system calls are being called
on a main GUI thread.

diff --git a/mythtv/libs/libmythbase/mythdbcon.cpp
b/mythtv/libs/libmythbase/mythdbcon.cpp
index 7ad204a..a578901 100644
--- a/mythtv/libs/libmythbase/mythdbcon.cpp
+++ b/mythtv/libs/libmythbase/mythdbcon.cpp
@@ -175,7 +175,9 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)
.arg(m_dbparms.wolCommand)); }

- sleep(m_dbparms.wolReconnect);
+ QTime sleepTime =
QTime::currentTime().addSecs(m_dbparms.wolReconnect);
+ while (QTime::currentTime() < sleepTime)
+
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
connected = m_db.open();
}

It seems to be working for me.

Roger


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
Roger,

Roger James <roger@beardandsandals.co.uk> writes:

> Here is a suggested patch against mythdbcon.cpp in 2.8-fixes. It could
> used at other places where sleep or other blocking system calls are
> being called on a main GUI thread.
>
> - sleep(m_dbparms.wolReconnect);
> + QTime sleepTime =
> QTime::currentTime().addSecs(m_dbparms.wolReconnect);
> + while (QTime::currentTime() < sleepTime)
> +
> QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents,
> 100);

One problem with this patch is that it will spin the CPU for the
wolReconnect idle time, which isn't very nice.

What exactly is the problem with using sleep()?

-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord@MIT.EDU PGP key available
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 7 February 2017 6:05:19 pm Derek Atkins <warlord@MIT.EDU> wrote:

>
> One problem with this patch is that it will spin the CPU for the
> wolReconnect idle time, which isn't very nice.
>

I agree that spinning isn't nice. But not pumping the event loop is worse.
A sleep(1) in the loop would improve things.

> What exactly is the problem with using sleep()?
>

See the start of this thread

Roger

 
 
 


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 8/02/2017 7:01 AM, Roger James wrote:
> On 7 February 2017 6:05:19 pm Derek Atkins <warlord@MIT.EDU> wrote:
>
>>
>> One problem with this patch is that it will spin the CPU for the
>> wolReconnect idle time, which isn't very nice.
>>
>
> I agree that spinning isn't nice. But not pumping the event loop is
> worse. A sleep(1) in the loop would improve things.
>
The correct Qt way is to use a QTimer and register/call a slot to
continue the processing after the time is up in another function. You
need to think event programming. Let the main loop of the thread do the
event dispatching. Blocking is bad even this way.
HTH
Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 7 February 2017 9:01:02 pm Mark Spieth <mark@digivation.com.au> wrote:

> On 8/02/2017 7:01 AM, Roger James wrote:
>> On 7 February 2017 6:05:19 pm Derek Atkins <warlord@MIT.EDU> wrote:
>>
>>>
>>> One problem with this patch is that it will spin the CPU for the
>>> wolReconnect idle time, which isn't very nice.
>>>
>>
>> I agree that spinning isn't nice. But not pumping the event loop is
>> worse. A sleep(1) in the loop would improve things.
>>
> The correct Qt way is to use a QTimer and register/call a slot to
> continue the processing after the time is up in another function. You
> need to think event programming. Let the main loop of the thread do the
> event dispatching. Blocking is bad even this way.
> HTH
> Mark

Agreed. That is correct way. Please read the start of this thread. This is
a simple fix for anyone who wants to try it. Yes it wastes CPU cycles. But
sleeping the main thread in mythfrontend just means that nothing will happen.

Paul has put a more GUI friendly startup window in master. But that will
not appear until 2.9.

R.

Roger


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: mythfrontend on ubuntu 17.04 testing X11 ICE problems [ In reply to ]
On 08/02/17 01:12, Roger James wrote:
> On 7 February 2017 9:01:02 pm Mark Spieth <mark@digivation.com.au> wrote:
>
>> On 8/02/2017 7:01 AM, Roger James wrote:
>>> On 7 February 2017 6:05:19 pm Derek Atkins <warlord@MIT.EDU> wrote:
>>>
>>>>
>>>> One problem with this patch is that it will spin the CPU for the
>>>> wolReconnect idle time, which isn't very nice.
>>>>
>>>
>>> I agree that spinning isn't nice. But not pumping the event loop is
>>> worse. A sleep(1) in the loop would improve things.
>>>
>> The correct Qt way is to use a QTimer and register/call a slot to
>> continue the processing after the time is up in another function. You
>> need to think event programming. Let the main loop of the thread do the
>> event dispatching. Blocking is bad even this way.
>> HTH
>> Mark
>
> Agreed. That is correct way. Please read the start of this thread.
> This is a simple fix for anyone who wants to try it. Yes it wastes CPU
> cycles. But sleeping the main thread in mythfrontend just means that
> nothing will happen.
>
> Paul has put a more GUI friendly startup window in master. But that
> will not appear until 2.9.
>
> R.
>
> Roger
>
Here is a final version of the patch. Most of the times this piece of
the code is called the gui is not on the screen. So the sleep can be
anything from 1 second up. However it should be less the the 90 second
timer that is effectively running in the X session manager since the
QCoreApplication has been instantiated. I disabled the processing of
user interaction events for safety reasons feel free to try with
QEventLoop::AllEvents.

Another fix for the XSM problem would to arrange for the
QCoreApplication to be created after OpenDatabase has been called, but
that is much more complex.

I have raised a bug on Qt for this. I think that Qt should set their own
ICE IO error handler and not just let the default one crash out of the
program on an exit(1). But they may well say, write your application
properly :-)


index 7ad204a..bdeb10d 100644
--- a/mythtv/libs/libmythbase/mythdbcon.cpp
+++ b/mythtv/libs/libmythbase/mythdbcon.cpp
@@ -175,7 +175,12 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)
.arg(m_dbparms.wolCommand));
}

- sleep(m_dbparms.wolReconnect);
+ QTime sleepTime =
QTime::currentTime().addSecs(m_dbparms.wolReconnect);
+ while (QTime::currentTime() < sleepTime)
+ {
+ QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
+ sleep(1); // Must not be longer than the X session
manager save session timeout (usually 90 seconds).
+ }
connected = m_db.open();
}

Roger
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org