Hi all!
During developing my application, I came across some strange problem with UIWebView. To be sure that the problem is not a side effect of some possible errors made by me elsewhere in the project, I created very simple new project but the problem still exists...
I created New NavigationBased project, and also created very simple class: WebViewController (subclass of UIViewController naturally). In WebViewController class I implemented only one method (of course dealloc still exists there

):
Code:
- (void)loadView {
[super loadView];
UIWebView *description = [[UIWebView alloc] initWithFrame:CGRectMake(10.0, 100.0, 300.0, 300.0)];
NSString *descWithHTML = [NSString stringWithFormat:@"<html><body>%@</body></html>", @"Test"];
[description loadHTMLString:descWithHTML baseURL:nil];
[self.view addSubview:description];
[description release];
}
Then, in RootViewController, I added following code:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Root";
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = @"Test";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
WebViewController *anotherViewController = [[WebViewController alloc] init];
[self.navigationController pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}
As you see, its very simple, and there shouldn't be any leaks.
If you then launch this application, you are presented UITableView with 2 clickable cells, and after selecting it, WebViewController is presented.
... the problem is, that
each time I create new UIWebView, new thread is started and gets blocked waiting for some semaphore infinitely till the application's termination!!!
The debugger says:
Quote:
Thread 5 (thread 12035):
#0 0x31dd6510 in __semwait_signal ()
#1 0x31d782d0 in _pthread_cond_wait ()
#2 0x31d77a94 in pthread_cond_wait ()
#3 0x31bd69a4 in WTF::ThreadCondition::wait ()
#4 0x35dca0ac in WebCore::LocalStorageThread::localStorageThread ()
#5 0x31d705a8 in _pthread_body ()
#6 0x00000000 in ?? ()
|
(to achieve this, get to the Console, pause application, and then type
thread apply all bt)
If I create 6 UIWebViews (by selecting some cell in RootViewController 6 times),
I just get 6 blocked, useless threads!!
Does anyone came across this problem also? Is there a solution to this problem? Or is it a bug in UIWebView implementation?
I spend whole day googling for this problem and found nothing strictly connected to this issue...
Thank you in advance for any suggestions.
--
ML