Tuesday, December 3, 2013

PieChart stays in detached DOM tree when removed from parent widget

I posted this to Stackoverflow and to the gwt-vizualization team as a possible bug, but I have not received any replies from either post.  Perhaps someone here has some insight into what is going on, or knows someone on the gwt-google-api team, or is on the team.

I have an MVP GWT 2.5.1 app using version 1.1.1 of gwt-visualization. My view has two Buttons and a VerticalPanel (accessed by the presenter as display.getPanel()). One button adds a PieChart to the VerticalPanel, the the other removes it. The presenter holds the PieChart reference as a Widget so that it knows when it has been added/removed. It is initialized to null.

I checked chrome's dev tools to ensure that the add/remove code wasn't creating a DOM leak. But after the PieChart was removed, its elements were left behind in a detached DOM tree, all color coded red. When I tried the same add/remove code with a Label instead of a PieChart, no detached DOM tree remained after removal.

I have a project on github that will reproduce this:

git clone https://github.com/akydd/GWT-experiments.git

Clone, build it, and deploy it so it can be run in Production mode.  It should have the following URL if deployed to the root folder of your local webserver: http://127.0.0.1/WidgetAddDelete.html.  Open it up in Chrome.

To see the issue, click the button on the first screen.  You should now see multiple buttons on screen.  Click "Add chart", wait for the chart to draw, then click "Remove chart".  Using Chrome's dev tools, take a heap snapshot.  You should see about 36 elements in the detached DOM tree that are left over from the removed PieChart:

It looks to me that there is a DOM leak with the PieChart widget.  Can someone confirm?  Or perhaps there is another way that I should be removing the PieChart widget?  I'm using the HasWidgets interface methods add(Wudget w) and remove(Widget w) to add and remove, respectively.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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/groups/opt_out.

No comments:

Post a Comment