Bug 122766

Summary: Safari: Do not track feature will always create a script controller for all iframes
Product: WebKit Reporter: Alexandru Chiculita <achicu>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: joepeck, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Alexandru Chiculita 2013-10-14 11:17:35 PDT
While debugging a test in the inspector-protocol I found that the script controller is always created in Safari. The test runner is not creating the script controller, so it has different behavior. A little bit of debugging showed the following stack. It seems like the do not track feature in Safari will always force the creation of the script controller.

I guess that avoiding the script controller as long as you don't have any scripts is a good optimization. At least applications that need no scripting and just use webkit to show up HTML/CSS content can avoid a little bit of memory overhead.

I've logged another bug in the new web inspector: https://bugs.webkit.org/show_bug.cgi?id=122764. The web inspector happens to use this side effect to show the iframes in the console & resource panel. Without this extension the iframes with no "script" tags will not show up in the WebInspector at all.

#0  WebCore::PageRuntimeAgent::notifyContextCreated (this=0x110409810, frameId=@0x7fff5fbfd288, scriptState=0x10abbefb0, securityOrigin=0x0, isPageContext=true) at /Users/achicu/code/webkit/Source/WebCore/inspector/PageRuntimeAgent.cpp:183
#1  0x000000010506ef79 in WebCore::PageRuntimeAgent::didCreateMainWorldContext (this=0x110409810, frame=0x110446a10) at /Users/achicu/code/webkit/Source/WebCore/inspector/PageRuntimeAgent.cpp:124
#2  0x000000010492aadd in WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl (instrumentingAgents=0x110407ac0, frame=0x110446a10, world=@0x11010ef80) at /Users/achicu/code/webkit/Source/WebCore/inspector/InspectorInstrumentation.cpp:155
#3  0x000000010455c06c in WebCore::InspectorInstrumentation::didClearWindowObjectInWorld (frame=0x110446a10, world=@0x11010ef80) at InspectorInstrumentation.h:517
#4  0x0000000104556d38 in WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld (this=0x110446aa8, world=@0x11010ef80) at /Users/achicu/code/webkit/Source/WebCore/loader/FrameLoader.cpp:3273
#5  0x0000000105434004 in WebCore::ScriptController::initScript (this=0x11043e5f0, world=@0x11010ef80) at /Users/achicu/code/webkit/Source/WebCore/bindings/js/ScriptController.cpp:229
#6  0x0000000101179fbf in WebCore::ScriptController::windowShell (this=0x11043e5f0, world=@0x11010ef80) at ScriptController.h:83
#7  0x0000000101172bad in WebCore::ScriptController::globalObject (this=0x11043e5f0, world=@0x11010ef80) at ScriptController.h:92
#8  0x000000010133e726 in WebKit::WebFrame::jsContextForWorld (this=0x1104561f0, world=0x1001b5810) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp:468
#9  0x00000001015611d2 in WKBundleFrameGetJavaScriptContextForWorld (frameRef=0x1104561f0, worldRef=0x1001b5810) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:105
#10 0x0000000112863c95 in Safari::BrowserBundlePageController::injectDoNotTrackDOMPropertyInStandardWorld ()
#11 0x000000011286ee37 in Safari::BrowserBundlePageLoaderClient::globalObjectIsAvailableForFrame ()
#12 0x00000001128e4fe2 in Safari::WK::globalObjectIsAvailableForFrame ()
#13 0x00000001010d504a in WebKit::InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame (this=0x111000308, page=0x111000000, frame=0x1104561f0, world=@0x11010ef80) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:298
#14 0x0000000101349cb9 in WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable (this=0x110468030, world=@0x11010ef80) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:1458
#15 0x000000010454b49b in WebCore::FrameLoader::dispatchGlobalObjectAvailableInAllWorlds (this=0x110446aa8) at /Users/achicu/code/webkit/Source/WebCore/loader/FrameLoader.cpp:3281
#16 0x000000010454b04e in WebCore::FrameLoader::receivedFirstData (this=0x110446aa8) at /Users/achicu/code/webkit/Source/WebCore/loader/FrameLoader.cpp:625
#17 0x0000000104300998 in WebCore::DocumentLoader::commitData (this=0x1110c5200, bytes=0x100509f30 "<html>\n <!--  <script>console.log(\"test\")</script> -->\n\n<body>\n\t<!-- Delay the onload event using a slow image -->\n\t<!-- <img src=\"http://localhost:8000/history/resources/slow-image.php\" /> -->\n</body"..., length=210) at /Users/achicu/code/webkit/Source/WebCore/loader/DocumentLoader.cpp:788
#18 0x0000000101347230 in WebKit::WebFrameLoaderClient::committedLoad (this=0x110468030, loader=0x1110c5200, data=0x100509f30 "<html>\n <!--  <script>console.log(\"test\")</script> -->\n\n<body>\n\t<!-- Delay the onload event using a slow image -->\n\t<!-- <img src=\"http://localhost:8000/history/resources/slow-image.php\" /> -->\n</body"..., length=210) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:856
#19 0x00000001043028b0 in WebCore::DocumentLoader::commitLoad (this=0x1110c5200, data=0x100509f30 "<html>\n <!--  <script>console.log(\"test\")</script> -->\n\n<body>\n\t<!-- Delay the onload event using a slow image -->\n\t<!-- <img src=\"http://localhost:8000/history/resources/slow-image.php\" /> -->\n</body"..., length=210) at /Users/achicu/code/webkit/Source/WebCore/loader/DocumentLoader.cpp:745
#20 0x0000000104302e8b in WebCore::DocumentLoader::dataReceived (this=0x1110c5200, resource=0x1005aa2b0, data=0x100509f30 "<html>\n <!--  <script>console.log(\"test\")</script> -->\n\n<body>\n\t<!-- Delay the onload event using a slow image -->\n\t<!-- <img src=\"http://localhost:8000/history/resources/slow-image.php\" /> -->\n</body"..., length=210) at /Users/achicu/code/webkit/Source/WebCore/loader/DocumentLoader.cpp:861
#21 0x0000000103f8f268 in WebCore::CachedRawResource::didAddClient (this=0x1005aa2b0, c=0x1110c5200) at /Users/achicu/code/webkit/Source/WebCore/loader/cache/CachedRawResource.cpp:137
#22 0x0000000103f97244 in WebCore::CachedResource::CachedResourceCallback::timerFired (this=0x1104571a0) at /Users/achicu/code/webkit/Source/WebCore/loader/cache/CachedResource.cpp:922
#23 0x0000000103f98a03 in WebCore::Timer<WebCore::CachedResource::CachedResourceCallback>::fired (this=0x1104571b0) at Timer.h:114
#24 0x0000000105750733 in WebCore::ThreadTimers::sharedTimerFiredInternal (this=0x11041d990) at /Users/achicu/code/webkit/Source/WebCore/platform/ThreadTimers.cpp:129
#25 0x0000000105750449 in WebCore::ThreadTimers::sharedTimerFired () at /Users/achicu/code/webkit/Source/WebCore/platform/ThreadTimers.cpp:105
#26 0x00000001054ea113 in WebCore::timerFired () at /Users/achicu/code/webkit/Source/WebCore/platform/mac/SharedTimerMac.mm:133
#27 0x00007fff894db804 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#28 0x00007fff894db31d in __CFRunLoopDoTimer ()
#29 0x00007fff894c0ad9 in __CFRunLoopRun ()
#30 0x00007fff894c00e2 in CFRunLoopRunSpecific ()
#31 0x00007fff8919eeb4 in RunCurrentEventLoopInMode ()
#32 0x00007fff8919ec52 in ReceiveNextEventCommon ()
#33 0x00007fff8919eae3 in BlockUntilNextEventMatchingListInMode ()
#34 0x00007fff82f63533 in _DPSNextEvent ()
#35 0x00007fff82f62df2 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#36 0x00007fff82f5a1a3 in -[NSApplication run] ()
#37 0x00000001012d7fef in WebKit::WebContentProcessMainDelegate::startRunLoop (this=0x7fff5fbff5d0) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/EntryPoint/mac/LegacyProcess/WebContentProcessMain.mm:171
#38 0x00000001012d702f in WebKit::ChildProcessMain<WebKit::WebProcess, WebKit::WebContentProcessMainDelegate> (argc=6, argv=0x7fff5fbff6f0) at ChildProcessEntryPoint.h:93
#39 0x00000001012d6d7b in WebContentProcessMain (argc=6, argv=0x7fff5fbff6f0) at /Users/achicu/code/webkit/Source/WebKit2/WebProcess/EntryPoint/mac/LegacyProcess/WebContentProcessMain.mm:183
#40 0x0000000100000d1d in WebKit::BootstrapMain (argc=6, argv=0x7fff5fbff6f0) at /Users/achicu/code/webkit/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:76
#41 0x0000000100000b92 in main (argc=6, argv=0x7fff5fbff6f0) at /Users/achicu/code/webkit/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:83
Comment 1 Radar WebKit Bug Importer 2013-10-14 11:19:17 PDT
<rdar://problem/15222457>
Comment 2 Timothy Hatcher 2013-10-14 14:13:37 PDT
Safari has a few features that execute scripts like AutoFill and apparently do-not-track. Thanks for the feedback, but this isn't something we would fix in WebKit. So marking this as invalid.