Hi everyone, I'm working on a Dashboard widget with a multi-threaded Cocoa plugin. The plugin seems to be working just fine, but I'm getting an occasional (frequent but inconsistent) crash that appears to indicate a bug in WebKit: ====================================================== Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000018 Thread 0 Crashed: 0 com.apple.WebCore 0x95c4a734 khtml::inlineWidth (khtml::RenderObject*, bool, bool) + 152 1 com.apple.WebCore 0x95c48b98 khtml::RenderBlock::findNextLineBreak(khtml::BidiIterator&, khtml::BidiState&) + 3548 2 com.apple.WebCore 0x95c46dbc khtml::RenderBlock::layoutInlineChildren(bool) + 1980 3 com.apple.WebCore 0x95c435d4 khtml::RenderBlock::layoutBlock(bool) + 692 4 com.apple.WebCore 0x95c4a49c khtml::RenderBlock::layoutPositionedObjects(bool) + 172 5 com.apple.WebCore 0x95c43930 khtml::RenderBlock::layoutBlock(bool) + 1552 6 com.apple.WebCore 0x95c4409c khtml::RenderBlock::layoutBlockChildren(bool) + 696 7 com.apple.WebCore 0x95c435ec khtml::RenderBlock::layoutBlock(bool) + 716 8 com.apple.WebCore 0x95c40524 khtml::RenderCanvas::layout() + 252 9 com.apple.WebCore 0x95c3fe08 KHTMLView::layout() + 792 10 com.apple.WebCore 0x95c52518 -[WebCoreBridge forceLayoutAdjustingViewSize:] + 56 11 com.apple.WebKit 0x959ce11c -[WebHTMLView layoutToMinimumPageWidth:maximumPageWidth:adjustingViewSize:] + 228 12 com.apple.WebKit 0x959e1328 -[WebHTMLView (WebPrivate) _web_layoutIfNeededRecursive] + 36 13 com.apple.WebKit 0x959cb8c0 -[WebHTMLView (WebPrivate) _propagateDirtyRectsToOpaqueAncestors] + 72 ... ====================================================== The crash is preceded by incorrect width of displayed divs, disappearing elements, or both. Does this seem to you to be a WebKit bug, or could there be a problem with my code? Ben
On Jul 9, 2005, at 8:24 PM, Ben Kazez wrote:
Hi everyone,
I'm working on a Dashboard widget with a multi-threaded Cocoa plugin. The plugin seems to be working just fine, but I'm getting an occasional (frequent but inconsistent) crash that appears to indicate a bug in WebKit:
====================================================== Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000018
Thread 0 Crashed: 0 com.apple.WebCore 0x95c4a734 khtml::inlineWidth (khtml::RenderObject*, bool, bool) + 152 1 com.apple.WebCore 0x95c48b98 khtml::RenderBlock::findNextLineBreak(khtml::BidiIterator&, khtml::BidiState&) + 3548 2 com.apple.WebCore 0x95c46dbc khtml::RenderBlock::layoutInlineChildren(bool) + 1980 3 com.apple.WebCore 0x95c435d4 khtml::RenderBlock::layoutBlock(bool) + 692 4 com.apple.WebCore 0x95c4a49c khtml::RenderBlock::layoutPositionedObjects(bool) + 172 5 com.apple.WebCore 0x95c43930 khtml::RenderBlock::layoutBlock(bool) + 1552 6 com.apple.WebCore 0x95c4409c khtml::RenderBlock::layoutBlockChildren(bool) + 696 7 com.apple.WebCore 0x95c435ec khtml::RenderBlock::layoutBlock(bool) + 716 8 com.apple.WebCore 0x95c40524 khtml::RenderCanvas::layout() + 252 9 com.apple.WebCore 0x95c3fe08 KHTMLView::layout() + 792 10 com.apple.WebCore 0x95c52518 -[WebCoreBridge forceLayoutAdjustingViewSize:] + 56 11 com.apple.WebKit 0x959ce11c -[WebHTMLView layoutToMinimumPageWidth:maximumPageWidth:adjustingViewSize:] + 228 12 com.apple.WebKit 0x959e1328 -[WebHTMLView (WebPrivate) _web_layoutIfNeededRecursive] + 36 13 com.apple.WebKit 0x959cb8c0 -[WebHTMLView (WebPrivate) _propagateDirtyRectsToOpaqueAncestors] + 72 ... ======================================================
The crash is preceded by incorrect width of displayed divs, disappearing elements, or both. Does this seem to you to be a WebKit bug, or could there be a problem with my code?
It's hard to tell. This bug sounds likely to be some kind of memory trasher, so it may be that something is corrupting memory. Is your plugin calling WebKit APIs from multiple threads? WebKit is not threadsafe so that is one possible cause. Can you reproduce it with just a plain web page with no plugin? If so, it would definitely be a WebKit bug. Regards, Maciej
In fact, I am calling WebKit APIs from multiple threads, which wasn't a good idea on my part. This is my first experience with multiple threads, and I'm enjoying it but am still quite a novice. My only WebKit call is to [WebView -stringByEvaluatingJavaScriptFromString:], so I've changed it to [_webViewLock lock]; [_webView stringByEvaluatingJavaScriptFromString:endHandlerJavaScript]; [_webViewLock unlock]; where _webViewLock is an instance variable in the Dashboard plugin object. However, the crash still happens -- some elements too tall, others too short, elements disappearing until you mouse over them, and then EXC_BAD_ACCESS. Should my locking code above have worked? (I can move this discussion to Cocoa-dev if it becomes off-topic for this list.) Thank you very much for your help. Ben On Jul 10, 2005, at 3:18 AM, Maciej Stachowiak wrote:
The crash is preceded by incorrect width of displayed divs, disappearing elements, or both. Does this seem to you to be a WebKit bug, or could there be a problem with my code?
It's hard to tell. This bug sounds likely to be some kind of memory trasher, so it may be that something is corrupting memory. Is your plugin calling WebKit APIs from multiple threads? WebKit is not threadsafe so that is one possible cause.
Can you reproduce it with just a plain web page with no plugin? If so, it would definitely be a WebKit bug.
Regards, Maciej
First I would like to point out this mailing list if for discussions about WebKit internal development. There is webkitsdk- dev@lists.apple.com for discussions about development of applications/ widgets using WebKit. You might have more exposure there. Simply locking around WebKit's WebView wont solve this problem. The reason is you don't know what other Cocoa classes or System APIs WebKit uses that aren't thread safe. Most Cocoa classes are publicly listed as not thread safe. There is a list of thread safe classes and other information here: http://developer.apple.com/documentation/Cocoa/Conceptual/ Multithreading/articles/CocoaSafety.html You might want to rethink your design, calling WebKit from only the main thread. This will save you many headaches. Most of WebKit's API is non-blocking and callback/delegate based, so threads really aren't needed. — Timothy Hatcher » colloquy.info On Jul 10, 2005, at 7:51 PM, Ben Kazez wrote:
In fact, I am calling WebKit APIs from multiple threads, which wasn't a good idea on my part. This is my first experience with multiple threads, and I'm enjoying it but am still quite a novice. My only WebKit call is to [WebView - stringByEvaluatingJavaScriptFromString:], so I've changed it to
[_webViewLock lock]; [_webView stringByEvaluatingJavaScriptFromString:endHandlerJavaScript]; [_webViewLock unlock];
where _webViewLock is an instance variable in the Dashboard plugin object. However, the crash still happens -- some elements too tall, others too short, elements disappearing until you mouse over them, and then EXC_BAD_ACCESS. Should my locking code above have worked? (I can move this discussion to Cocoa-dev if it becomes off-topic for this list.)
Thank you very much for your help.
Sorry about posting to the wrong list. In my case, I really do need multiple threads due to the interaction between the widget plugin and the widget's WebView, so I set up some notification-passing to do the WebKit API calls from the main thread. Not only is it working, but I now know more about threads as a result of your response. Thanks very much! Ben -- Ben Kazez http://www.benkazez.com On Jul 10, 2005, at 9:09 PM, Timothy Hatcher wrote:
First I would like to point out this mailing list if for discussions about WebKit internal development. There is webkitsdk- dev@lists.apple.com for discussions about development of applications/widgets using WebKit. You might have more exposure there.
Simply locking around WebKit's WebView wont solve this problem. The reason is you don't know what other Cocoa classes or System APIs WebKit uses that aren't thread safe. Most Cocoa classes are publicly listed as not thread safe.
There is a list of thread safe classes and other information here:
http://developer.apple.com/documentation/Cocoa/Conceptual/ Multithreading/articles/CocoaSafety.html
You might want to rethink your design, calling WebKit from only the main thread. This will save you many headaches. Most of WebKit's API is non-blocking and callback/delegate based, so threads really aren't needed.
— Timothy Hatcher » colloquy.info
On Jul 10, 2005, at 7:51 PM, Ben Kazez wrote:
In fact, I am calling WebKit APIs from multiple threads, which wasn't a good idea on my part. This is my first experience with multiple threads, and I'm enjoying it but am still quite a novice. My only WebKit call is to [WebView - stringByEvaluatingJavaScriptFromString:], so I've changed it to
[_webViewLock lock]; [_webView stringByEvaluatingJavaScriptFromString:endHandlerJavaScript]; [_webViewLock unlock];
where _webViewLock is an instance variable in the Dashboard plugin object. However, the crash still happens -- some elements too tall, others too short, elements disappearing until you mouse over them, and then EXC_BAD_ACCESS. Should my locking code above have worked? (I can move this discussion to Cocoa-dev if it becomes off- topic for this list.)
Thank you very much for your help.
participants (3)
-
Ben Kazez
-
Maciej Stachowiak
-
Timothy Hatcher