Hi, I’m writing a small widget application rendering a couple of NSView subclasses which update periodically. The widgets are subclasses of [1] and added as subviews to my main view, but the more I add the more likely are some random errors thrown on initialization. The errors include a variety of failed assertions and seg faults (see [2] for examples) and don’t yield any helpful clues. I’m guessing that I’m dealing with something not thread-safe here. Am I doing something wrong here? I’m doing all the drawing inside the drawRect(rect) method (or synchronously called methods) which I don’t call manually. “update” pulls data from various resources, but doesn’t draw. [1] WidgetView class: http://pastie.textmate.org/private/hwfozrwudk2lcwzker20q [2] Different Errors: http://pastie.textmate.org/private/vbp7iuw11ig26zxegzg Jan
Hi Jan, Indeed this looks like a classic threading problem. I thought we eliminated most of these in 0.6. What does your #update method do specifically? Also, do the problems disappear if you call #update only once from the main thread before starting the thread? A minor (but likely irrelevant here) note: I think your drawRect: method might be called from the thread, which is AFAIK not supported in Cocoa. Laurent On May 15, 2010, at 8:25 AM, Jan Kassens wrote:
Hi,
I’m writing a small widget application rendering a couple of NSView subclasses which update periodically.
The widgets are subclasses of [1] and added as subviews to my main view, but the more I add the more likely are some random errors thrown on initialization. The errors include a variety of failed assertions and seg faults (see [2] for examples) and don’t yield any helpful clues. I’m guessing that I’m dealing with something not thread-safe here.
Am I doing something wrong here? I’m doing all the drawing inside the drawRect(rect) method (or synchronously called methods) which I don’t call manually. “update” pulls data from various resources, but doesn’t draw.
[1] WidgetView class: http://pastie.textmate.org/private/hwfozrwudk2lcwzker20q [2] Different Errors: http://pastie.textmate.org/private/vbp7iuw11ig26zxegzg
Jan _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks Laurent, Moving the #update method seems to fix the issue. I’m going to try something different for the periodical update (mutex with global timer or something…) If you want to see my (dumb) code to track down the threading issues, I just pushed it to github at: http://github.com/kassens/AwesomeWidgets Jan On May 15, 2010, at 21:24, Laurent Sansonetti wrote:
Hi Jan,
Indeed this looks like a classic threading problem. I thought we eliminated most of these in 0.6.
What does your #update method do specifically? Also, do the problems disappear if you call #update only once from the main thread before starting the thread?
A minor (but likely irrelevant here) note: I think your drawRect: method might be called from the thread, which is AFAIK not supported in Cocoa.
Laurent
On May 15, 2010, at 8:25 AM, Jan Kassens wrote:
Hi,
I’m writing a small widget application rendering a couple of NSView subclasses which update periodically.
The widgets are subclasses of [1] and added as subviews to my main view, but the more I add the more likely are some random errors thrown on initialization. The errors include a variety of failed assertions and seg faults (see [2] for examples) and don’t yield any helpful clues. I’m guessing that I’m dealing with something not thread-safe here.
Am I doing something wrong here? I’m doing all the drawing inside the drawRect(rect) method (or synchronously called methods) which I don’t call manually. “update” pulls data from various resources, but doesn’t draw.
[1] WidgetView class: http://pastie.textmate.org/private/hwfozrwudk2lcwzker20q [2] Different Errors: http://pastie.textmate.org/private/vbp7iuw11ig26zxegzg
Jan _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
I traced the bug down to a small script, but can’t get it smaller than this: http://pastie.textmate.org/private/m21wkng3mgu7wvksbu4rq According to the apple documentation [1] the Calendar Store framework is thread safe, but removing it removes the seg faults and bus errors I’m getting. It might just be Obj C calls from threads? If this is a bug, I can file a ticket, but I might as well be doing something stupid here. [1]: http://developer.apple.com/mac/library/documentation/AppleApplications/Refer... Jan On May 15, 2010, at 21:24, Laurent Sansonetti wrote:
Hi Jan,
Indeed this looks like a classic threading problem. I thought we eliminated most of these in 0.6.
What does your #update method do specifically? Also, do the problems disappear if you call #update only once from the main thread before starting the thread?
A minor (but likely irrelevant here) note: I think your drawRect: method might be called from the thread, which is AFAIK not supported in Cocoa.
Laurent
On May 15, 2010, at 8:25 AM, Jan Kassens wrote:
Hi,
I’m writing a small widget application rendering a couple of NSView subclasses which update periodically.
The widgets are subclasses of [1] and added as subviews to my main view, but the more I add the more likely are some random errors thrown on initialization. The errors include a variety of failed assertions and seg faults (see [2] for examples) and don’t yield any helpful clues. I’m guessing that I’m dealing with something not thread-safe here.
Am I doing something wrong here? I’m doing all the drawing inside the drawRect(rect) method (or synchronously called methods) which I don’t call manually. “update” pulls data from various resources, but doesn’t draw.
[1] WidgetView class: http://pastie.textmate.org/private/hwfozrwudk2lcwzker20q [2] Different Errors: http://pastie.textmate.org/private/vbp7iuw11ig26zxegzg
Jan _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Jan, I tried your snippet but it works fine for me. I didn't get any crash. But your environment might differ from mine. In any case, it should not crash, so please file a ticket and attach the crash log (or a full threads backtrace from gdb), and I will have a look :) Thanks, Laurent On May 18, 2010, at 3:49 PM, Jan Kassens wrote:
I traced the bug down to a small script, but can’t get it smaller than this: http://pastie.textmate.org/private/m21wkng3mgu7wvksbu4rq According to the apple documentation [1] the Calendar Store framework is thread safe, but removing it removes the seg faults and bus errors I’m getting. It might just be Obj C calls from threads?
If this is a bug, I can file a ticket, but I might as well be doing something stupid here.
[1]: http://developer.apple.com/mac/library/documentation/AppleApplications/Refer...
Jan
On May 15, 2010, at 21:24, Laurent Sansonetti wrote:
Hi Jan,
Indeed this looks like a classic threading problem. I thought we eliminated most of these in 0.6.
What does your #update method do specifically? Also, do the problems disappear if you call #update only once from the main thread before starting the thread?
A minor (but likely irrelevant here) note: I think your drawRect: method might be called from the thread, which is AFAIK not supported in Cocoa.
Laurent
On May 15, 2010, at 8:25 AM, Jan Kassens wrote:
Hi,
I’m writing a small widget application rendering a couple of NSView subclasses which update periodically.
The widgets are subclasses of [1] and added as subviews to my main view, but the more I add the more likely are some random errors thrown on initialization. The errors include a variety of failed assertions and seg faults (see [2] for examples) and don’t yield any helpful clues. I’m guessing that I’m dealing with something not thread-safe here.
Am I doing something wrong here? I’m doing all the drawing inside the drawRect(rect) method (or synchronously called methods) which I don’t call manually. “update” pulls data from various resources, but doesn’t draw.
[1] WidgetView class: http://pastie.textmate.org/private/hwfozrwudk2lcwzker20q [2] Different Errors: http://pastie.textmate.org/private/vbp7iuw11ig26zxegzg
Jan _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On 19 May 2010, at 00:19, Laurent Sansonetti wrote:
I tried your snippet but it works fine for me. I didn't get any crash. But your environment might differ from mine.
Out of interest I tried his snippet, and it segfaulted for me too. https://gist.github.com/7f75c2aa6bd1544befab has my crash report. I'm running 0.6 stable installed from the .pkg. HTH, C --- Caius Durling caius@caius.name +44 (0) 7960 268 100 http://caius.name/
participants (3)
-
Caius Durling
-
Jan Kassens
-
Laurent Sansonetti