Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization event race condition fix #205

Merged

Conversation

IanCaunce
Copy link

Hi,

I noticed in some browsers, mainly older browsers such as IE9 and <= Android 4.3, the iframe would fail to resize upon page render, especially if the cache had been cleared.

There was a race condition whereby a resize message would fire before an init message was received.

In this race condition, the order of events was as follows:

Host: init
Host: resize
Host: iframe.load

The first init message would fail as the child iframe had not finished rendering. The resize event would then fire causing the width and height to be stored on the closure. The child would respond but the the id would be an empty string as the plugin wasn't initialized. Execution on the host would then fail as settings[iframeID] was undefined and you attempt to access the log attribute on line 352.

When the second init event was fired, the plugin would be setup as expected, but because the width & height had already been set by the previous resize message, the child iframe would simply output No change in size detected.

This pull request prevents reset & resize message from triggering a resize event before the plugin has been initialized. If a message is received before initialization, a warning will be outputted to the console.

Thanks, Ian

@davidjbradshaw
Copy link
Owner

Thank you for this and good spot.

@davidjbradshaw davidjbradshaw merged commit 883fb4d into davidjbradshaw:master May 19, 2015
@davidjbradshaw
Copy link
Owner

Released v2.8.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants