I am developing a GWT app using eclipse and I was wondering if there is a way to hot swap client code changes I make without having to do a full Google Compile each time. Currently when I modify my code, I do a Google compile and then click the Reload server button, then I refresh my browser to pick up the changes. This is starting to get a bit painful as it takes 10 - 20 sec to do a full compile when I may have only modified a UI string so was wondered is there a quicker way.
If you want to see your changes in client code, hit the refresh button in your browser.
If you need debug functions, use Debug As => Web Application. It may be a little (or a lot) slower to start depending on a browser.
If you don't need debug functionality, use Run As => Web Application. It starts faster. You will still see all errors in Development Mode and Console tabs.
If you make changes to server-side code, you have to reload the web server, using the dedicated button of the dedicated Development Mode view in Eclipse.
You never need to recompile unless the plugin tells you to do it.
See https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideDevMode
To add to Andrei's answer Assuming we are changing functionality invoked on button click.
1) We usually change lines of code in the function invoked and click the button again in the UI. No need of reloaing the entire application using refresh button.
2) If the change involves code that cannot be hotswapped - example class changes like adding new a class variable, then you need to refresh browser. You can sometimes ignore the eclipse warning complaining that it cannot hot-swap.
3) If you run out of memory then you need to close and relaunch dev mode.
4) If your server side is hogging memory then it might be better idea to use external server rather than jetty to avoid time consumed on server restart for every dev mode launch.
Related
I'm testing a custom WPF application using pywinauto.
When connecting with win32, I don't get any dependents, so I'm connecting with uia.
After I launch the application, I can immediately connect with pywinauto, but it takes 30s+ before I'm able to access any elements. After the initial delay, interacting and searching for controls is quick.
I call windows() as a way to wait until the application lets me interact with it.
main_app = Application(backend="uia").connect(path=APP_PATH)
main_app.windows()
On investigation, the hanging seems to occur during: "application.py" > "windows" > "findwindows.find_elements(...)" > "element.children(...).
If I open the application, and wait for 1 minute, and then run the script, then it occurs almost immediately. And finding subsequent controls is quick.
I appear to see this same behaviour when using inspect.exe to view the hierarchy. If I refresh immediately after opening the application, it takes 30s+ to show anything. But If I wait a minute before refreshing, it updates immediately.
I was wondering if someone else had experienced this before, and what might be the cause/solution.
I am running:
Windows 10, python 3.8.3, pywinauto 0.6.8
Sometimes setting an application as an firewall exceptions helps them boot/open faster.
Granting Firewall exception on Windows 10 for an application:
Go to Control Panel.
Click Windows Firewall or Windows Defender Firewall option.
Choose option "Allow an app or feature through Windows Firewall" (on left side).
Select your application in the list or click on Add Another App to find it and add it to list.
After debugging some more, I have resolved the issue, although it's not clear to me what the root cause actually was.
The custom application I'm testing launches a background application as a non-visible console. Testing showed that not running this background application allowed me to conenct immediately. Running the background application by itself would cause the same delay in inspect.exe loading.
The application was a dotnet framework application, that in theory was a console only application, but had code supporting a WPF interface (which was not displayed). By removing the WPF aspects of the project, I was able to build the application as a purely console application, and I no longer experienced the earlier delays.
When running my code in debug mode, I keep getting 2 error messages:
Could not delete [path_to]\productiondb.log. May be locked by another process
I don't know what process might be locking it. It comes when I make changes to the code while my Pivotal tc Server is running in debug mode, but it dosent seem to create a lot's of trouble. Sometimes however, I get this warning:
Also due to some changes. I usally just restart the server and move on. This isen't the real problem, the real problem is that I get these messages when I havent doen any changes. Somethimes it accures when I run a certen part of the code, other times i occurs when I open certen codes in sts, however, it doen't seem to stop at the same place twice.
I am suspecting that this has something to do with git. I am using git to change between versions and doing tests. So I am thinking that STS has some of the code in memory from before I changed branche with git, and isen't updating it before I run or open the file with that code. But I am rather new to both sts and git, and can't be certan that it would work that way. If it is, does anyone know how to update sts after I have changed branch? If it is not, does anyone know what might causing it?
If you run an app in debug mode, the Eclipse Debugger tells the application when code gets changed and tries to use the debug API to swap in the new code into the running application. This is especially useful if you debug your code, hit a breakpoint, step through the code, fit the issue, change the code, and press save. At that moment, the Eclipse compiler updates the class file and tells the running JVM to swap in the new code. If that succeeds, the debugger will jump back to the last stack frame and the execution of your app will continue with the beginning of the method that you entered. This allows you to directly continue to debug and step through the updated code without restarting the app.
While this is a great feature of the JVM, it is very limited in terms of what scope of changes to the classes the JVM can deal with while doing this hot-swap. It is usually limited to method implementations. So adding new methods, adding or deleting members of the class, etc, are not supported. As a result, the above screenshot will appear. It means that the JVM wasn't able to hot-swap the changed code and will continue to run with the previously loaded code instead of the changed one.
I have started creating my first project with GWT. In first lines of code, it worked normally and I had no need to GWT Compile every time to see a simple change in my browser.
For client changes, a save file was enough and for server a save and refresh server. But now it has stopped working like before.
For the smallest change like adding a "Window.alert("msg")" I need to reGWTCompile the whole project to see it! What could have issued this?
Make sure you're running in DevMode (i.e. have ?gwt.codesvr= in your URL)
I was doing a small project and everytime I run the program, I can feel more lag and delay, until it is completely not working anymore.
I checked with the task managers and found many "Javaw.exe" Instances. Then I opened the debug field and realize that it runs a new instance everytime I run the same project.
here is the link to image of the instances in debug area.
http://i50.tinypic.com/2hz4spu.png
The temporary solution for me is to terminate them from the debug area. Is there any way to prevent the same project from creating a new instance everytime it is run ? I only need one instance that can be reused everytime I run again and again.
Thanks for any response in advance.
No, I'm sure that's not what you want. If you restart an application, it's probably that you want to test some changes you've just made in the code. So Eclipse needs to start a new instance of your application. You could also want to start two instances of an app because they need to talk to each other.
If you want previously launched applications to stop, then stop them. Your app seems to be a GUI app. Use the close button on the main frame of the app to close it. As simple as that.
It's often not desired to kill an application, because it might need to properly close resources, or tell the server it's leaving before exiting, or whatever. Having Eclipse kill apps without a conscious request from the user would not be wise.
I've read in so many places that code-splitting can significantly speed up the initial loading time of a GWT application.
However, before we do the splitting, we would like to know whether the deferred download of codes also work when in development mode?
Currently our most painful point is that in development mode with debug mode, when we refresh the browser (to refresh the changes in client code) it will take 3.7 years for the app to reload.
In production mode the application will load in a matter of seconds.
Code splitting has absolutely no effect in Dev Mode, because your application is not compiled to JavaScript.
When GWT.isScript() is false (Dev Mode) RunAsyncCallback.onSuccess() method is run immediately. It is apparent if you inspect the source code of the GWT.runAsync() method.
EDIT: just a small thing to add as well: do NOT use Chrome with DevMode. Chrome still has an outstanding bug (the link escapes me right now) that makes the DevMode Plugin for Chrome run really slowly. Use Firefox, it is the fastest with the Dev Mode plugin.
As said before code splitting has absolutely no effect in Dev Mode.
Only thing that I could suggest you is to increase memory for jvm on start:
For example we use in our project:
-Xmx1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:PermSize=256M -XX:MaxPermSize=512M
Also upgrade your working hardware(CPU, memory), it's could help you to compile faster your java code on Dev mode.
If you want faster DevMode you should be more careful with how you write your application. User lazy loading where possible, split app into standalone modules.
E.g. let's say you have some app with 5000 classes. And usually a developer needs to change only some part of application, not all application (one page for example). So basically you need to make sure that to start one simple part of app, only classes needed by the app are loaded. E.g. instead of loading 5000 classes only 100 will be loaded. Also check for common errors like RPC Type Explosion, they affect devmode as well. And try GWT 2.4 it is much faster than previous versions (I mean DevMode).
In my (medium length) experience I noticed Internet Explorer 9 is also pretty fast in Dev Mode, and a lot more stable than Chrome. The GWT plug-in doesn't crash every other reload of the application.
You could give it a try, see if it works better for you.