History | Log In     View a printable version of the current page.  
Issue Details (XML)

Key: SDK-14250
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: B B
Assignee: Joann Chuang
Reporter: Joann Chuang
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Flex SDK

createChildren gets called twice when extending Window

Created: 01/08/08 05:44 PM   Updated: 01/21/08 09:14 PM
Component/s: AIR: Window
Security Level: Public (All JIRA Users )

File Attachments: 1. XML File 2app.xml (0.6 kb)
2. File children.mxml (0.4 kb)
3. File children.swf (242 kb)
4. File MyClass.as (0.4 kb)


Severity: Incorrectly Functioning with Workaround
Reproducibility: Every Time
Discoverability: Medium
Found in Version: SDK Moxie RC2 - 3.0.0.126
Milestone: SDK Moxie RC2
Affected OS(s): All OS Platforms
Steps to Reproduce:
Steps to reproduce:
1. Compile the attached bug files.
2. Run the file
 
 Actual Results:
 Notice the trace output says "In create children" twice
 
 Expected Results:
 Should only call createChildren() once.
 
 Workaround (if any):
 
 
 
Language Found: English
Bugbase Id: none
Triaged: Yes
Regression: No
QA Owner: Joan Lafferty
Resolved by: Ryan Frishberg
Fixed Version: SDK Flex 3 (Released) - Next Build
Confirmed Version: SDK Moxie RC2 - 3.0.0.256
Participants: Joan Lafferty, Joann Chuang, Lauren Park and Ryan Frishberg


 All   Comments      Sort Order:
Joan Lafferty - [01/09/08 12:32 PM ]
reproduced in build 127. Sending to IRB.

Lauren Park - [01/09/08 03:13 PM ]
PFR for workaround.

Ryan Frishberg - [01/09/08 05:01 PM - edited ]
Ok, I have the framework fix. Unfortunately, the workaround isn't that great. SystemManager/Application have a complex way of starting up, and unfortunately, this was copied into WindowedSystemManger/Window but wasn't done 100% correctly.

In normal circumstances (non-SystemManager/Application), when a child is added we call addingChild(child), $addChild(child), and childAdded(child). $addChild is the Flash addChild method. The other two methods are bookkeeping and do some extra stuff (childAdded is the method that ends up calling createChildren())

For SystemManager/Application, SystemManager is the top-level class, and we want to add Application as a child to that class. Normally, we would do: addingChild(child), $addChild(child), and childAdded(child); however, this is a special case, and we don't do it that straight-forward (perhaps for performance reasons, though I'm not 100% sure that's still the case today). Instead, we do: addingChild(child), childAdded(child), and then later after all the children have been created, we add it to the Flash display list with $addChild(child).

WindowedSystemManager tried to copy this functionality over; however, it's not quite right. What actually happens is:
1. addingChild(child)
2. childAdded(child)
3 addChild(child) -- should be $addChild(child)

Step #3 in turn calls addingChild(child), $addChild(child), and childAdded(child), which is why createChildren() gets called twice.

Ok, so that's the problem. The workaround is to:

1. Extend WindowedSystemManager and add $addChild(child) as a method that just calls super.child(child). This is needed so we can call this method later on.
2. When you extend Window, the place where WindowedSystemManager is created is in Window.commitProperties(), so what you need to do is override this method (without calling super.commitProperties, which means you'll have to look at super.commitProperties() and copy all that stuff too and everything it's dependent on -- not just in Window.commitProperties() but all the way up the class hierarchy chain since we cannot call super.super.commitProperties()). However, change 2 things. Change where the WIndowedSystemManager is created to the class you created in step #1. Also change sm.addChild(this) to sm.$addChild(this), so we don't get the extra calls to addingChild(child) and addChild(child).

I wish it was easier, but unfortunately it's not.

Ryan Frishberg - [01/09/08 05:12 PM - edited ]
The other option for the workaround is to monkeypatch Window and copy all the code, changing commitProperties() as needed. This way you don't have to worry about copying all of the super.commitProperties() stuff and all it's dependent on. Again, not really a great workaround.

The workaround I can think of sucks (I've asked Gordon to take a look to see if he can think of anything else). However, the fix inside the framework code isn't that bad.

Ryan Frishberg - [01/09/08 05:46 PM ]
Talked to Gordon. We can't think of a simple, realistic workaround. We both think this is a fundamental problem because it affects component livecycle and should be fixed in the framework.

Lauren Park - [01/10/08 02:03 AM ]
PFR - cyclone has been provided, tested and approved.

Ryan Frishberg - [01/10/08 05:43 PM ]
Fixed in 154.

Joann Chuang - [01/21/08 09:14 PM ]
Verified in build 249. createChildren only gets called once.