JDK-8152315 : Don't server / request the Cached resource for if its Main resource is explicitly cancelled
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2016-03-21
  • Updated: 2020-01-31
  • Resolved: 2016-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
1. BrowserEngine.load("www.test1.com");
2. loadworker1 is still RUNNING 
3. BrowserEngine.load("www.test2.com"); 
4. Loadworker1 == Cancel && Loadworker 2 == RUNNING 

Some of the pending cached scripts (Image, CSS, Scripts) which are async load or pending load (resource which are updated from css or from delayed JavaScript load) are loaded for test1.com even after test2.com is loading. 


Comments
Duplicate of JDK-8153501
27-04-2016

Possible duplicate of JDK-8153501.
09-04-2016

[~ghb] Thanks for the info..I will check and let you know...
01-04-2016

[~mbilla]Different Loaders and object ownership is already explained in my earlier comments. Specific to CachedResourceLoader please ref : http://trac.webkit.org/wiki/MemoryCache , this give fair understanding about the memory cache and the object hierarchy. URLLoader.java (SocketTimeoutException) --> LoadListenerClient.CONNECTION_TIMED_OUT --> [native] UrlLoader::twkDidFail --> ResourceHandleClient::didFail , Further to this on native currently setTimeout is not being set. or to make it simple, "LoadListenerClient.CONNECTION_TIMED_OUT" error code is never parsed and mapped to ResourceError as timeout !. The test content used loads webpage every 12 seconds and LoadListenerClient.CONNECTION_TIMED_OUT is 30 seconds. There is no relation i could see to implement or consider timeout for this defect. "brief code walk through " CachedResourceLoader::canRequest is called from below methods and those method names are self explanatory CSSStyleSheet::canAccessRules RuleSet::addRulesFromSheet StyleSheetContents::parseAuthorStyleSheet ScriptElement::notifyFinished ScriptExecutionContext::sanitizeScriptError DocumentLoadTiming::addRedirect DocumentThreadableLoader::DocumentThreadableLoader FrameLoader::commitProvisionalLoad ImageLoader::notifyFinished ResourceLoader::didReceiveAuthenticationChallenge SubresourceLoader::willSendRequest TextTrackLoader::notifyFinished (feature not used in our platform) CachedResourceLoader::requestImage ContentSecurityPolicy::stripURLForUseInReport (Static) EventSource::connect History::stateObjectAdded w.r.t WebCore::FrameState FrameStateProvisional : Main page (Root Document i.e .htm / .html file if we consider html web page) is being start to load FrameStateCommittedPage : valid data of Main Page data is received which is enough for parsing FrameStateComplete : Main page and its immediate Embedded data (js, css, fonts, images) is received. NOTE : Not the lazyloading or "async" are loaded after FrameStateComplete , search for "responsive web design" will list some of the different patterns (w.r.t. web content development and not for GOF) of loading js, css, fonts, background images which can be loaded in asynchronous way. Do give specific scenario or class or objects which is not clear to my comments .
01-04-2016

[~ghb] ok...any idea if page load time out happens ? may be point 2 can be ignored if no call is being made to setIsTimeout(true) I suggest you can just give a brief code walk through of your understanding regarding this fix so that review can be expedited.
31-03-2016

[~mbilla] (1) : m_documentLoader is assigned in CachedResourceLoader constructor and will be nullified from DocumentLoader::~DocumentLoader() --> m_cachedResourceLoader->clearDocumentLoader(); Please check CachedResourceLoader::frame() method which check for m_documentLoader null and makes this flag "shouldBypassMainWorldContentSecurityPolicy" as false. If you walk through the code except "if (options.requestOriginPolicy == RestrictToSameOrigin && !m_document->securityOrigin()->canRequest(url)) {" i didn't any ref m_documentLoader being used even after shouldBypassMainWorldContentSecurityPolicy being false. "if ( !m_documentLoader) return false;" for Non Provisional load and isCancellation conditions. I might introduce regression for returning false by only checking for the m_documentLoader being null. (2) : NOTE Resource Error is set from Platform specific context, I Didn't see any "setIsTimeout(true)" is being set from our FrameLoaderClientJava nor from URLLoader.
31-03-2016

[~ghb] 2 Quick comments . Will continue review further. 1. You can add else case for if (m_documentLoader) { and return false; OR if ( !m_documentLoader) return false; 2. Do you also want to check for m_documentLoader->mainDocumentError().isTimeout ?? if (!m_documentLoader->mainDocumentError().isNull() && (m_documentLoader->mainDocumentError().isCancellation() || m_documentLoader->mainDocumentError().isTimeout() ))
31-03-2016

Webrev : http://cr.openjdk.java.net/~ghb/8152315/webrev.01/ Navigating from one page (PageA) to another page (PageB) Case 1 : PageA partially loaded , (Frame State : Committed and Sub resource are still downloading or in ResourceLoadScheduler queue) solution : DocumentLoader should not load resources if the user cancel which is set from FrameLoader::stopAllLoader() Case 2 (Heap Corruption) : PageA completely loaded , (Async resources i.e JavaScript, css, fonts, background images, svg) Don't request for sub-resource during Frame state is provisional. Root cause : Loading sub resources of pageA (during provisional state) will end up creating SubResourceLoader and CachedResourceLoader object in context to PageB's DocumentLoader. Cached resources objects are created from either ScriptRunner, HTMLScriptRunner and ResourceLoadScheduler. After PageB is committed, PageA's Document will be destroyed from JS garbage collector. a. PageA committed state Async resources are loading b. FrameLoader::load('PageB'), Creates new DocumentLoader (which will be now Active DocmentLoader) c. ScriptRunner timers loads PageA's sub resource c.1 : new CachedResource objects created and add's to ResourceLoadScheduler c.2 : if their is enough connection pool exists in ResourceLoadScheduler, it will create a SubResourceLoader d. PageB main resource received the data, DocumentLoader::setFrame(PageB's frame) Between step c and step d, CachedResource which are created will be in context of pageB's DocumentLoader where as CachedResourceLoader will have PageA's DocumentLoader object. While deleting PageB document (from JavaScript GC), SubResourceLoader and CachedResourceLoaders are de-referenced (or referring an already deleted object). Solution : Don't load sub resource during Provisional state. Steps to Reproduce : use : gflags /i JAVA_HOME/bin/java.exe +hpa [https://msdn.microsoft.com/en-us/library/windows/hardware/ff543094(v=vs.85).aspx] or user Windows Application verifier (which gives GUI option for setting various GFlags for application under test) and DebugDiag ref : https://blogs.msdn.microsoft.com/lagdas/2008/06/24/debugging-heap-corruption-with-application-verifier-and-debugdiag/ Run the Attached Test application (Use "Start Auto load") with above GFlag set. Application will crash if there is a heap corruption , in our test case the crash occurs at CachedResourceLoader::decrementRequestCount as the object is already deleted from PageA's JS garbage collect.
30-03-2016

Testing : Attached Sample application which loads webpage from a timer. Time value can be modified with the slider provided. Select "Start Auto load" to start loading live webpages. Unit test limitation : Need live webpage or test content which has more than 5 sub resources. Need to add logs to confirm the cached resource request made even after main resource loaders is set to error or is cancelled.
21-03-2016

Webrev : http://cr.openjdk.java.net/~ghb/8152315/webrev.00/ RC and Solution : Life cycle of a CachedResourceLoader CachedResourceLoader is Per Frame responsible for loading All the Cached resource for a frame and it will be deleted once the frame is detached (Replaced by new frame). Frame : has at least One Main Document --> DocumentLoader --> CachedResourceLoader --> CachedResource --> ResourceLoadScheduler --> SubResourceLoader (ResourceLoader) --> URLLoader ResourceLoadScheduler maintains cached resource queue based on the max number of http request per host (current setting is 5 per host). on 3rd step (mentioned in the description) a. FrameLoader -- stops all the loaders b. DocumentLoader -- Stop loading c. DocumentLoader -- set Main Cancelled error -999 and isStopping flag on 4th Step a. FrameLoader -- Request a new resource b. New DocumentLoader is created and requests its Main resource c. Document will be replaced (Detached with old frame and attached with new parsed, rendered frame) Before 4.c is complete, Current (test1.com) page is active and its prepaint and async load timers will be active (running). These can request Pending resource from ResourceLoadScheduler. Solution : Avoid loading pending resources / async scripts based on Main resource error type or with is Cancellation flag.
21-03-2016