Re: User interface unresponsive in window

2015-04-17 Thread Jonathan Taylor
 Am I right in thinking that when running under Xcode any drawing errors will 
 be logged to the Xcode console?
 
 No, not unless they’re actually exceptions. Messages from other processes are 
 only going to appear in the system log.

OK, thanks for your suggestion about checking the system log then - I will look 
out for that.

 With puzzling, intermittent errors like this, I often find that reading your 
 own code carefully may be more productive than going to heroic debugging 
 extremes. The trick is not to prejudge *where* in your code you should look. 
 (Don’t be the person looking underneath the street light for a dropped 
 quarter because “that’s where the light is”.)

That's a fair suggestion, but taken in its most general sense that is a 
near-impossible task. There are 100-odd source files in the project, etc, and 
just code-read the project and look for some bug is a non-starter. Are you 
effectively saying that you agree with my hypothesis that the cause is 
GUI-related code being executed on a non-main thread? If you or others have 
definitely seen that cause problems of this sort in the past, then I'll 
certainly do a second more thorough read-through of any code that could 
possibly be relevant...

Cheers
Jonny

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: User interface unresponsive in window

2015-04-17 Thread Uli Kusterer
On 15 Apr 2015, at 16:04, Jonathan Taylor jonathan.tay...@glasgow.ac.uk wrote:
 I've started encountering intermittent problems in one specific window in my 
 application, where text input boxes become unresponsive, steppers remain 
 highlighted after clicking, etc. I'm rather short of ideas on how to debug 
 this, particular since I haven't worked out how to reproduce it reliably. 
 Other windows seem to remain unaffected.
 
 From dimly-remembered past experience I have a feeling it could be related to 
 something somewhere resulting in GUI code being executed on a non-main 
 thread. There is in principle a risk of that, since the window interacts with 
 peripherals/drivers etc involving multithreaded code. I've tried to isolate 
 the GUI code from the multithreaded code, but may perhaps have missed some 
 obscure case. [ideally, I'd probably totally isolate anything multithreaded 
 from ObjC code, but that would mean a proliferation of shadow classes, which 
 is something I'd prefer to avoid being dragged into]
 
 Even if my suspicion about the cause (multithreading+GUI) is correct, I'm 
 still not sure how to pin down and debug the problem, since there are so many 
 entry points into GUI-related code (e.g. property value changes), not all of 
 which even involve my own code directly. It would be great if there was some 
 way of enabling a global exception if main-thread requirements are 
 violated, but I certainly haven't heard of such a thing (and can imagine 
 there could be very good reasons why it would be prohibitively hard to 
 implement). Can anyone suggest ways to diagnose and debug my problem (or 
 indeed suggest other possible causes I haven't thought of)?

A few ideas:

- access of UI from non-main thread, corrupting data
- view inserted as subview of one of its superviews
- Someone calling one of the nextEventMatchingMask: methods and swallowing 
events that someone else is looking for to end a loop.
- Exception thrown from tracking code
- Someone calling display: from inside drawRect:, causing an endless recursion

Have you tried just pausing your app in the debugger when this happens and 
looking at each thread to see what is running?

Cheers,
-- Uli
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: User interface unresponsive in window

2015-04-17 Thread Kyle Sluder
On Fri, Apr 17, 2015, at 04:16 AM, Jonathan Taylor wrote:
 That's a fair suggestion, but taken in its most general sense that is a
 near-impossible task. There are 100-odd source files in the project, etc,
 and just code-read the project and look for some bug is a non-starter.


Before you embark on such a task, you might try breaking on -[NSCell
drawWithFrame:inView:] or a similar method that you know is being called
as part of the badness.

The problem there is that you don't know if the issue is at the callsite
that triggers the drawing. But it's likely enough that it's worth
starting your search there.

 Are you effectively saying that you agree with my hypothesis that the
 cause is GUI-related code being executed on a non-main thread? If you or
 others have definitely seen that cause problems of this sort in the past,
 then I'll certainly do a second more thorough read-through of any code
 that could possibly be relevant...

You might also have an issue with runloops—either you're touching the UI
from a thread that doesn't have a running runloop, or you've got a
nested runloop invocation on your main thread, and it's never escaping
some special mode (like NSEventTrackingRunLoopMode). Either way, the
result is that code sets up a timer or delay-perform that never fires,
which might explain the symptoms you're seeing.

--Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
I've started encountering intermittent problems in one specific window in my 
application, where text input boxes become unresponsive, steppers remain 
highlighted after clicking, etc. I'm rather short of ideas on how to debug 
this, particular since I haven't worked out how to reproduce it reliably. Other 
windows seem to remain unaffected.

From dimly-remembered past experience I have a feeling it could be related to 
something somewhere resulting in GUI code being executed on a non-main thread. 
There is in principle a risk of that, since the window interacts with 
peripherals/drivers etc involving multithreaded code. I've tried to isolate the 
GUI code from the multithreaded code, but may perhaps have missed some obscure 
case. [ideally, I'd probably totally isolate anything multithreaded from ObjC 
code, but that would mean a proliferation of shadow classes, which is something 
I'd prefer to avoid being dragged into]

Even if my suspicion about the cause (multithreading+GUI) is correct, I'm still 
not sure how to pin down and debug the problem, since there are so many entry 
points into GUI-related code (e.g. property value changes), not all of which 
even involve my own code directly. It would be great if there was some way of 
enabling a global exception if main-thread requirements are violated, but I 
certainly haven't heard of such a thing (and can imagine there could be very 
good reasons why it would be prohibitively hard to implement). Can anyone 
suggest ways to diagnose and debug my problem (or indeed suggest other possible 
causes I haven't thought of)?

Thanks in advance
Jonny
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: User interface unresponsive in window

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 07:04 , Jonathan Taylor jonathan.tay...@glasgow.ac.uk 
wrote:
 
 From dimly-remembered past experience I have a feeling it could be related to 
 something somewhere resulting in GUI code being executed on a non-main thread.

You can at least start by trying the simple things, if you haven’t tried them 
already:

— Make sure you have an Objc-C exception breakpoint set in Xcode at all times.

— Use the Console utility to look in the system log for errors about incorrect 
drawing calls in your app.

There’s not much chance this will get you off easily, but it’s a quick start.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
Thanks for the suggestions. Am I right in thinking that when running under 
Xcode any drawing errors will be logged to the Xcode console? That's certainly 
what I've seen in the past (but not in relation to this problem - haven't seen 
anything in the Xcode console at all for this).

Any other ideas from anyone? Has anybody seen similar symptoms ever in the past 
(GUI not responding properly in one single window)?


On 15 Apr 2015, at 18:01, Quincey Morris quinceymor...@rivergatesoftware.com 
wrote:

 On Apr 15, 2015, at 07:04 , Jonathan Taylor jonathan.tay...@glasgow.ac.uk 
 wrote:
 
 From dimly-remembered past experience I have a feeling it could be related 
 to something somewhere resulting in GUI code being executed on a non-main 
 thread.
 
 You can at least start by trying the simple things, if you haven’t tried them 
 already:
 
 — Make sure you have an Objc-C exception breakpoint set in Xcode at all times.
 
 — Use the Console utility to look in the system log for errors about 
 incorrect drawing calls in your app.
 
 There’s not much chance this will get you off easily, but it’s a quick start.
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: User interface unresponsive in window

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 14:54 , Jonathan Taylor jonathan.tay...@glasgow.ac.uk 
wrote:
 
 Am I right in thinking that when running under Xcode any drawing errors will 
 be logged to the Xcode console?

No, not unless they’re actually exceptions. Messages from other processes are 
only going to appear in the system log.

With puzzling, intermittent errors like this, I often find that reading your 
own code carefully may be more productive than going to heroic debugging 
extremes. The trick is not to prejudge *where* in your code you should look. 
(Don’t be the person looking underneath the street light for a dropped quarter 
because “that’s where the light is”.)



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com