Initialization event race condition fix #205
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aninit
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]
wasundefined
and you attempt to access thelog
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