Changeset 19458 in webkit
- Timestamp:
- Feb 6, 2007 7:50:43 PM (17 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r19449 r19458 1 2007-02-06 Kevin Decker <kdecker@apple.com> 2 3 Fixed: <rdar://problem/4976681> ASSERTION failure on quit @ talkcrunch.com in _NPN_ReleaseObject 4 5 Reviewed by Anders. 6 7 * Plugins/WebPluginDatabase.m: 8 (+[WebPluginDatabase sharedDatabase]): Removed NSApplicationWillTerminateNotification observer and thus 9 also removed code that would unload the entire plug-in database when receiving that notification. 10 11 The bug here was that this notification callback would happen first before anything else thus unloading 12 plug-ins and releasing plug-in memory. That was crash prone because the JavaScriptCore collector would at 13 a later time attempt to release its CInstance references (references that point to plug-in memory) 14 without knowing WebKit already unloaded the plug-in out from underneath it. The WebPluginDatabase simply 15 does not have enough context to make this decision. 16 17 * WebView/WebView.mm: Added two statics: applicationIsTerminating, pluginDatabaseClientCount. 18 (+[WebView initialize]): Added NSApplicationWillTerminateNotification observer. 19 (+[WebView _applicationWillTerminate]): Added. 20 (-[WebView _close]): WebKit has both a global plug-in database and a separate, per WebView plug-in database. 21 We need to release both sets of plug-ins because Netscape plug-ins have "destructor functions" that should be 22 called when the browser unloads the plug-in. These functions can do important things, such as closing/deleting 23 files so it is important to ensure that they are properly called when the application terminates. 24 25 The new change is that on app shutdown, we unload WebKit's global plug-in database if and only if the last WebView 26 was closed. To do so otherwise would unload plug-ins out from underneath other WebViews. 27 1 28 2007-02-06 Darin Adler <darin@apple.com> 2 29 -
trunk/WebKit/Plugins/WebPluginDatabase.m
r18424 r19458 48 48 - (void)_removePlugin:(WebBasePluginPackage *)plugin; 49 49 - (NSMutableSet *)_scanForNewPlugins; 50 - (void)_applicationWillTerminate;51 50 @end 52 51 … … 61 60 [sharedDatabase setPlugInPaths:[self _defaultPlugInPaths]]; 62 61 [sharedDatabase refresh]; 63 64 // Clear the global plug-in database on app exit65 [[NSNotificationCenter defaultCenter] addObserver:sharedDatabase66 selector:@selector(_applicationWillTerminate)67 name:NSApplicationWillTerminateNotification68 object:NSApp];69 62 } 70 63 … … 375 368 } 376 369 377 - (void)_applicationWillTerminate378 {379 ASSERT(self == sharedDatabase);380 // Remove all plug-ins from database. Netscape plug-ins have "destructor functions" that should be called381 // when the browser unloads the plug-in. These functions can do important things, such as closing/deleting files,382 // so it is important to ensure that they are properly called when the application terminates.383 [self close];384 }385 386 370 @end -
trunk/WebKit/WebView/WebView.mm
r19295 r19458 232 232 macro(yankAndSelect) \ 233 233 234 static BOOL applicationIsTerminating; 235 static int pluginDatabaseClientCount = 0; 236 234 237 @interface NSSpellChecker (AppKitSecretsIKnow) 235 238 - (void)_preflightChosenSpellServer; … … 308 311 BOOL selectWordBeforeMenuEvent; 309 312 313 // WebKit has both a global plug-in database and a separate, per WebView plug-in database. Dashboard uses the per WebView database. 310 314 WebPluginDatabase *pluginDatabase; 311 315 … … 392 396 if (!self) 393 397 return nil; 394 395 398 allowsUndo = YES; 396 399 textSizeMultiplier = 1; … … 398 401 shouldCloseWithWindow = objc_collecting_enabled(); 399 402 continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled]; 403 400 404 #ifndef BUILDING_ON_TIGER 401 405 grammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled]; … … 404 408 405 409 identifierMap = new HashMap<unsigned long, RetainPtr<id> >(); 410 pluginDatabaseClientCount++; 406 411 407 412 return self; … … 652 657 _private->hasSpellCheckerDocumentTag = NO; 653 658 } 654 659 660 [[NSNotificationCenter defaultCenter] removeObserver:self]; 661 [WebPreferences _removeReferenceForIdentifier: [self preferencesIdentifier]]; 662 pluginDatabaseClientCount--; 663 664 // Make sure to close both sets of plug-ins databases because plug-ins need an opportunity to clean up files, etc. 665 666 // Unload the WebView local plug-in database. 655 667 if (_private->pluginDatabase) { 656 668 [_private->pluginDatabase close]; … … 658 670 _private->pluginDatabase = nil; 659 671 } 660 661 [[NSNotificationCenter defaultCenter] removeObserver:self];662 663 [WebPreferences _removeReferenceForIdentifier: [self preferencesIdentifier]];672 673 // Keep the global plug-in database active until the app terminates to avoid having to reload plug-in bundles. 674 if (!pluginDatabaseClientCount && applicationIsTerminating) 675 [[WebPluginDatabase sharedDatabase] close]; 664 676 } 665 677 … … 1444 1456 // this prevents open source users from crashing when using the Show DOM Tree menu item in Safari 1445 1457 // FIXME: remove this when it is no longer needed to prevent Safari from crashing 1446 + (void)initialize1458 + (void)initialize 1447 1459 { 1448 1460 static BOOL tooLate = NO; … … 1450 1462 if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"IncludeDebugMenu"]) 1451 1463 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_finishedLaunching) name:NSApplicationDidFinishLaunchingNotification object:NSApp]; 1464 1465 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp]; 1452 1466 tooLate = YES; 1453 1467 } 1454 1468 } 1455 1469 1456 +(void)_finishedLaunching 1470 + (void)_applicationWillTerminate 1471 { 1472 applicationIsTerminating = YES; 1473 if (!pluginDatabaseClientCount) 1474 [[WebPluginDatabase sharedDatabase] close]; 1475 } 1476 1477 + (void)_finishedLaunching 1457 1478 { 1458 1479 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_removeDOMTreeMenuItem:) name:NSMenuDidAddItemNotification object:[NSApp mainMenu]];
Note: See TracChangeset
for help on using the changeset viewer.