I just discovered a behavior in GWT that was unexpected and has some performance implications and I wanted to see if anyone has any thoughts on the subject.
-- When a window close event occurs, the RootPanel CloseHandler fires and it explicitly detaches all of its child widgets. This causes those widgets to execute their onDetach and onUnload methods. I noticed this because I recently made a change to cause auto-unregistering of various object model change events in our widgets' onUnload methods. But then I discovered that this is happening on window close the effect of which is that when the user reloads the page or tries to navigate to another page, there is a noticeable delay while all those onDetach events are processed.
This seems incredibly wasteful. The object model change events we have certainly don't need to get unregistered when the window is closing. It's like putting away your laundry and vacuuming the house right before you go outside and demolish the whole house. I've always assumed that when the window is closed, everything is just summarily abandoned and the next for explicit cleanup was unnecessary. I have a feeling that the reason for this behavior is because of memory leaks in certain browsers. Is that actually the case? If so, is there a way to do the necessary cleanup in a faster manner without executing the unnecessary cleanup. It seems to me that the onUnload methods would generally not need to be called on window closing. Are these leaks specific to certain browsers and this detaching is not required for the others? Or perhaps there could be a mechanism for you to short-circuit code in your onUnload if you see that it's occurring as the result of a window close.
At a minimum it seems like there should be some best practices around what you put in on onUnload method. If hundreds or thousands of those are going to all get called at once on window close, that could be bad.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment