This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 253507 - 99% in BrowserSupport.getBrowserURL()
Summary: 99% in BrowserSupport.getBrowserURL()
Status: RESOLVED WONTFIX
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-16 07:01 UTC by terje7601
Modified: 2016-05-27 11:40 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans snapshot (1.58 MB, application/octet-stream)
2015-07-16 07:01 UTC, terje7601
Details

Note You need to log in before you can comment on or make changes to this bug.
Description terje7601 2015-07-16 07:01:17 UTC
Created attachment 154667 [details]
NetBeans snapshot

While NetBeans was doing its background checks, CPU usage was unusually high.

Product Version: NetBeans IDE Dev (Build 201507150001)
Java: 1.8.0_51; Java HotSpot(TM) 64-Bit Server VM 25.51-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_51-b16
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 Tomas Hurka 2015-07-17 12:31:17 UTC
Most of the time is spent in BrowserSupport.getBrowserURL() in FileUtil-Refresh-All thread. Reassign to web/html project. Please evaluate.
Comment 2 Tomas Mysik 2015-07-22 11:36:59 UTC
I can see that most of time is spent in:

org.openide.filesystems.FileUtil.normalizeFile()	34.030685	51 308 ms (34%)	51 308 ms

Reassigning, please evaluate. Thanks.
Comment 3 Jaroslav Havlin 2015-07-30 13:44:10 UTC
Method FolderObj.getFileObject(String relativePath) calls FileUtil.normalizeFile() only if relativePath contains "./", "..", or "/."

Maybe we could investigate what relativePath values are passed from o.n.m.web.common.api.WebUtils.resolveToReference and, if possible, modify them to avoid the problematic substring.

(I'd prefer not to modify FolderObj's getFileObject implementation, which could be quite risky.)
Comment 4 Tomas Mysik 2015-07-31 05:28:40 UTC
(In reply to Jaroslav Havlin from comment #3)
> Maybe we could investigate what relativePath values are passed from
> o.n.m.web.common.api.WebUtils.resolveToReference and, if possible, modify
> them to avoid the problematic substring.

No idea but will try to look at it. Thanks for the hint.
Comment 5 Jaroslav Havlin 2015-10-22 14:14:32 UTC
> Maybe we could investigate what relativePath values are passed from
> o.n.m.web.common.api.WebUtils.resolveToReference and, if possible,
> modify them to avoid the problematic substring.
The paths passed to WebUtils.resolveToReference are usually relative paths contained in HTML source files, e.g. in src="path" or href="path", which is correct and should not be fixed.

The slowness occurred probably due to some external change. Background scanning was in progress and, at the same time, HTML5 project started checking whether the browser should be refreshed. It checks (if I understand correctly) if the changed file is a dependency of the file displayed in the browser. This is the place where normalization of paths takes place.

The only place that can possibly be improved is o.n.m.web.clientproject.DependentFileQueryImpl, which retrieves (and also normalizes) all dependencies, although only one dependency is checked.
This may be a problem when the file references many resources (e.g. .css and .js files). It would be better to retrieve and normalize only the queried dependency.

But (!) after the connection to browser is established, implementation of DependentFileQuery from module Webkit Tooling (o.n.m.web.webkit.tooling.networkmonitor.DependentFileQueryImpl) is usually used, which does not need to normalize the files. So the slow implementation is used only temporarily.

My conclusion is that the main culprit is slow filesystem (it can happen sometimes, especially on NTFS). Improving o.n.m.web.clientproject.DependentFileQueryImpl may help, but the slow filesystem will probably block other important parts of the OS anyway.

Reassigning back to web/HTML Project.
Tomas, please decide whether the suggested fix is appropriate. 

> While NetBeans was doing its background checks, CPU usage was unusually high.
Terje7601, can you still reproduce the bug with newer development builds?
Comment 6 terje7601 2015-10-23 07:05:56 UTC
(In reply to Jaroslav Havlin from comment #5)
> Terje7601, can you still reproduce the bug with newer development builds?

I haven't had this issue since I reported it, but that may simply be because it's hard to reproduce. Either way, thanks for investigating this.
Comment 7 Tomas Mysik 2015-10-23 07:19:15 UTC
I will have a look at DependentFileQueryImpl, thanks Jardo.
Comment 8 Tomas Mysik 2016-05-27 11:40:31 UTC
I tried to investigate DependentFileQueryImpl but it seems to me that getAllDependencies() method cannot be avoided (sorry if I am wrong, I do not know anything about the HTML editor).

@jhavlin: Jardo, if you are interested in this issue, feel free to have a look at it, of course.

So, closing as WONTFIX. Thanks for reporting.