Issue with multiple applications when using multiple windows

I have a strange issue. I have a vaadin application with multiple window support, I have followed the instructions on the wiki to enable multiple window support by overriding the getWindow method. This works great when I access the application from multiple browser tabs/windows.

I however run into a strange problem when I embed this application into an iframe. I have a portlet that embeds a url into an iframe. If i use the same application it works fine if I have one instance of the portlet on the page, however if I place 2 or more strange things start happening.

Sometimes it just works, but most of the time I start getting invalid security key errors when I interact with the app on a portlet that wasn’t the last one loaded. Looking into this, when it doesn’t work I am getting multiple application instances created, which from my understanding should not happen. As I look through the AbstractApplicationServlet code it appears that I might have a concurrency issue where applications are not created yet when a new request is coming in, and hence a new application is created. Does this sound like a possibility, or does anyone have any ideas what may cause this behavior to occur. The path is the same as these are the same application.

**UPDATE
This is reproducible with a simple html file using iframe. The html file looks like this.

<html>
<body>
<iframe name="JSIframe" id="tomaxJSIframe" src="http://localhost:8280/vaadinapp/vaadin?param1=a&amp;param2=0-5F341F38DD612EDD37C44B486C5E91589F8C118059C44C69-1 width="100%" height="650px" scrolling="auto" frameborder="0">Your browser does not support frames</iframe>

<iframe name="JSIframe" id="tomaxJSIframe" src="http://localhost:8280/vaadinapp/vaadin?param1=b&amp;param2=0-5F341F38DD612EDD37C44B486C5E91589F8C118059C44C69-1 width="100%" height="650px" scrolling="auto" frameborder="0">Your browser does not support frames</iframe>
</body>
</html>

You may have to manually name those windows to prevent the conflicts (entirely untested but might be worth a try)

Instead of http://localhost:8280/vaadinapp/vaadin?param1=a&am
Try http://localhost:8280/vaadinapp/1-1/vaadin?param1=a&am http://localhost:8280/vaadinapp/1-2/vaadin?param1=a&am