gleydson404 / flex-iframe

Automatically exported from code.google.com/p/flex-iframe
0 stars 0 forks source link

Problem rendering iframes when used in tab navigator #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the code included below
2. App opens with Tab 1 - google.com selected and properly rendered
3. Select Tab 2 - yahoo.com properly renders
4. Select Tab 3 - Tab 3 appears selected, but yahoo.com iframe is still
rendered.
5. Click back to Tab 2 or 1 then back to tab 3 - boston.com now properly
renders - I thought it may be a latency issue but I've also tried other
sites for Tab 3.

What version of the product are you using? On what operating system?
Win XP
iframe 3_1_3_2

Please provide any additional information below.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:local="*">
    <mx:TabNavigator width="95%" height="95%" x="10" y="10">
        <mx:Canvas label="Tab 1" width="100%" height="100%">
            <local:IFrame id="f1"
                label="f1"
                source="http://www.google.com"
                width="100%"
                height="100%"/>
        </mx:Canvas>
        <mx:Canvas label="Tab 2" width="100%" height="100%">
            <local:IFrame id="f2"
                label="f2"
                source="http://www.yahoo.com"
                width="100%"
                height="100%"/>
        </mx:Canvas>
        <mx:Canvas label="Tab 3" width="100%" height="100%">
            <local:IFrame id="f3"
                label="f3"
                source="http://www.boston.com"
                width="100%"
                height="100%"/>
        </mx:Canvas>        
    </mx:TabNavigator>
</mx:Application>

Original issue reported on code.google.com by alan.pla...@gmail.com on 4 Nov 2008 at 8:39

GoogleCodeExporter commented 9 years ago
I'm still looking into this but it either has something to do with the 
TabNavigator
not doing the right thing wrt visibility or something to do with the fact that 
the
showing/hiding of iframes is done in the iframe component's set visible 
property.  I
believe, although I need to confirm, that if an ancestor is shown/hidden, 
children
may not have their visibility explicitly set.  In other languages, I think to 
get a
component's explicit visiblity you would just use the property, but if you 
wanted to
get its state (which may be affected by an ancestor) you would call isVisible or
something like that.  Not sure how this is handled in Flex though.

Original comment by alan.pla...@gmail.com on 4 Nov 2008 at 8:42

GoogleCodeExporter commented 9 years ago
Not sure if this is going to help your specific implementation, but if you 
remove the
Canvas controls and allow the IFrames to be the only children / a direct child 
of the
TabNavigator, the problem is resolved. Must be something about the way the 
IFrame
traverses the view stack to accomplish the showing/hiding of the actual HTML 
iframe;
I've had similar problems and took a bit of hacking to get it all dialed in 
(still
not sure what my problem was exactly, or what I changed to fix it).

Original comment by dealingwith on 4 Nov 2008 at 10:55

GoogleCodeExporter commented 9 years ago
Oh, I remember one problem I am still having, I am using SuperTabNavigator from
FlexLib, which includes "close" buttons for each tab. When closing a 
"background" tab
w/ an IFrame in it (a tab that is not the currently-viewed tab), it breaks the 
IFrame
stuff fairly severely.

Original comment by dealingwith on 4 Nov 2008 at 10:57

GoogleCodeExporter commented 9 years ago
dealingwith - For your issue with closing tabs, check out this other issue that 
I
logged.  I think that's what you are seeing.
http://code.google.com/p/flex-iframe/issues/detail?id=1

I'll try removing the Canvas and see if that helps my tab selection issue.

Original comment by alan.pla...@gmail.com on 4 Nov 2008 at 11:44

GoogleCodeExporter commented 9 years ago
If you set creationPolicy="all" on the TabNavigator, that seems to resolve the 
issue. When creationPolicy is the 
default (auto), the TabNavigator creates only its immediate children when it 
initializes. Their children (i.e. the 
iframes inside the canvases) are not created until that tab is visited.

This would suggest that it's an issue with creation timing or order. I'm 
investigating further

Original comment by ryan2...@gmail.com on 5 Nov 2008 at 6:30

GoogleCodeExporter commented 9 years ago
OK, I figured this one out -- the problem was with code that I added to iframe 
to detect potential cross-site 
scripting violations. This code uses the BrowserManager to find out the 
application's domain when iframe runs 
createChildren. When new iframes were getting created using the deferred auto 
creationPolicy, they were 
calling BrowserManager.initForHistoryManager() again which was causing 
HistoryManager to re-set the 
application's history state, including the selected tab of the TabNavigator.

I've fixed this so that initForHistoryManager should only ever get called once, 
the first time the IFrame .

I will try to get an updated version to Alistair that has a couple of other 
fixes as well for stuff I've run into. In 
the meantime, you can fix it by hand:

1. Change 
private var appHost:String 
 -- to --
private static var appHost:String;

2. Wrap the BrowserManager and appHost block in createChildren() in a check for 
appHost being already set, 
so it looks like this:
// Get the host info to check for cross-domain issues
if (!appHost)
{
       BrowserManager.getInstance().initForHistoryManager();
       var url:String = BrowserManager.getInstance().url;
       appHost = URLUtil.getProtocol(url) + "://" 
              + URLUtil.getServerNameWithPort(url);
}

Sorry 'bout that one. Hope that helps.

Ryan

Original comment by ryan2...@gmail.com on 5 Nov 2008 at 8:10

GoogleCodeExporter commented 9 years ago
Sweet!  that seems to work.  Thanks for looking into this so quickly.

Original comment by alan.pla...@gmail.com on 5 Nov 2008 at 8:25

GoogleCodeExporter commented 9 years ago
Closing this issue...

Original comment by ryan2...@gmail.com on 10 Nov 2008 at 5:09

GoogleCodeExporter commented 9 years ago

Original comment by Julien.N...@gmail.com on 11 Oct 2009 at 12:20