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 228826 - Changing source SASS/LESS file in Java Web proj does not immediately refresh page in browser
Summary: Changing source SASS/LESS file in Java Web proj does not immediately refresh ...
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: Inspection (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Marek Fukala
URL:
Keywords: RANDOM
Depends on: 213141
Blocks:
  Show dependency tree
 
Reported: 2013-04-22 00:33 UTC by David Konecny
Modified: 2013-06-06 01:51 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2013-04-22 00:33:25 UTC
This is very similar to the issue 228190 but for Java Web Project (I just enabled CSS Processors in Java Web proj - ecca9103a943). There is some synchronization issue because CSS gets refreshed in browser if SASS is saved second time. Or if I debug the code the browser seems to get refreshed correctly. I'm not sure what's wrong though.
Comment 1 Jan Stola 2013-05-15 12:38:42 UTC
I am not able to reproduce this issue reliably but I was able to reproduce it after few attempts. Moreover, this issue doesn't seem to be specific to Java Web project, I was able to reproduce it with HTML5 project as well.

I have added some debugging messages into SassExecutable and CSS.setStyleSheeetText to see whether the file was compiled, whether the refresh was invoked in the browser and what data has been passed to the browser.

When the problem occured then the logs showed that SASS->CSS compilation was invoked and that the content of the corresponding stylesheet was updated in the browser. Unfortunately, the document from which the CSS data were retrieved still contains the old version of the file.

I have no idea what can be the root of this problem. I am reassigning this issue to tmysik (who is responsible for css.prep) for evaluation.
Comment 2 Tomas Mysik 2013-06-04 07:24:48 UTC
(In reply to comment #1)
> Unfortunately, the document from which the CSS data were retrieved
> still contains the old version of the file.

Editor guys, how this can happen? Would anybody know? I really have no idea what could/should I do... Is there anything I can do in compilers themselves (e.g. wait 1 second or similarly)? If not, who is the proper assignee of this issue? Marek?

Thanks.
Comment 3 Tomas Mysik 2013-06-04 09:37:08 UTC
I did investigate it a bit and it reminded me issue #213141 (which is WONTFIX, BTW). What do you think, is it the same? It seems to me to be the same, the workaround was to wait 1 second after changing the file (Jarda Tulach's advice).

If anybody has objections, please comment otherwise I will do it tomorrow.

Thanks.
Comment 4 Marek Fukala 2013-06-04 14:45:16 UTC
I cannot help much as I am not familiar with the whole flow.

I guess it works this way:

1) SASS  document is modified by user
=> no action
2) SASS document is saved to file by user
=> triggers autocompilation (via what mechanism? index refresh?)
3) CSS *file* content is replaced by the SASS compiler
-> now I just guess:
=> The CSS file's document is reloaded upon the underlying file change. 
=> if the CSS file is "focused" in the CSS styles then the CSS source model is refreshed upon change in the document. 
=> now the browser is told to refresh its content (there used to be the css "live update") - is this the way how it works?

Tomasi, I think I need to deep dive into the problem to be able to help. But I will do that if you don't mind. I'm sorry, but adding 1 seconds delays it really the last resort and I'd like to take a look at it first.
Comment 5 Tomas Mysik 2013-06-05 05:21:58 UTC
(In reply to comment #4)
> 2) SASS document is saved to file by user
> => triggers autocompilation (via what mechanism? index refresh?)

No, file change listener is used.

> 3) CSS *file* content is replaced by the SASS compiler
> -> now I just guess:
> => The CSS file's document is reloaded upon the underlying file change. 
> => if the CSS file is "focused" in the CSS styles then the CSS source model is
> refreshed upon change in the document. 
> => now the browser is told to refresh its content (there used to be the css
> "live update") - is this the way how it works?

Honzo, can you confirm it please?

> Tomasi, I think I need to deep dive into the problem to be able to help. But I
> will do that if you don't mind. I'm sorry, but adding 1 seconds delays it
> really the last resort and I'd like to take a look at it first.

I totally agree with you, of course, that is why I asked someone who knows something about the editor to look at this issue. Thanks a lot for taking this issue over.

Thanks.
Comment 6 Jan Stola 2013-06-05 09:42:37 UTC
> > 3) CSS *file* content is replaced by the SASS compiler
> > -> now I just guess:
> > => The CSS file's document is reloaded upon the underlying file change. 
> > => if the CSS file is "focused" in the CSS styles then the CSS source model
> > is refreshed upon change in the document. 
> > => now the browser is told to refresh its content (there used to be the css
> > "live update") - is this the way how it works?
> 
> Honzo, can you confirm it please?

No, see SassExecutable.compile(). When the compilation (i.e. the external process) is finished then the file-system is asked to refresh the resulting files. LiveUpdater (i.e. the refresh of the files in the browser) is invoked then explicitly (via UiUtils.refreshCssInBrowser). Unfortunately, the LiveUpdater sometimes retrieves the old content from the given document.
Comment 7 Marek Fukala 2013-06-05 11:31:25 UTC
fixed in web-main#51f441f3f6af
Comment 8 Quality Engineering 2013-06-06 01:51:26 UTC
Integrated into 'main-golden', will be available in build *201306052301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/51f441f3f6af
User: Marek Fukala <mfukala@netbeans.org>
Log: #228826 - Changing source SASS/LESS file in Java Web proj does not immediately refresh page in browser