Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
Adobe Flex SDK 4.1 (Release)
-
None
-
None
-
Affected OS(s): All OS Platforms
Affected OS(s): All OS Platforms
Browser: Safari
Language Found: English
Description
Steps to reproduce:
1. Animate the alpha, x, y, z, rotationY, rotationX, width, and height of 10 component for 3 seconds
2. Over 2,000 events are dispatched, ALL OF WHICH ARE NOT BEING LISTENED TOO
3. Same with Data Serialization. Create an ArrayCollection with 1000 items and the application freezes. TOO MUCH UNNECESSARY BINDING.
Actual Results:
AN ENORMOUS AMOUNT OF EVENTS ARE BEING DISPATCHED, which don't have listeners, which takes up VITAL bytes, which causes animations and data serialization to look choppy because the single-threaded flash player can't handle all every frame!
Expected Results:
CONDITIONAL EVENT DISPATCHING. I have attached a SOLID Solution to this problem, and it's in my Flex SDK Sandbox, all the tests pass, and it doesn't break anything.
Workaround (if any):
Integrate this into the framework, please don't keep building with this unregulated event dispatching system, it's making it very difficult to make the application have fluid animations, and it's just plain not necessary.
Please take a detailed look at the attached 3 files, they're very short classes. They are everything required to solve this problem, all of the code works and can be immediately integrated into the Flex SDK. This is the only thing preventing me from using your SDK builds. If you integrate this in, it will help all of us out.
In there are a few key principles:
1) Only dispatch events if there is something listening for it. Requires checking a) if hasEventListener(type), or b) if something has set "useCapture = true" in the application (so say the main Application can hear "xChanged" on a child nested 10 deep (it doesn't "hasEventListener", but it set useCapture=true).
2) Always dispatch events via methods named after the event: dispatchBindableEvent, dispatchFlexEvent, dispatchStateChangeEvent, etc. This allows the application to CHECK before it creates the event, saving a LOT of resources, especially during ANIMATIONS and DATA SERIALIZATION. Never do: dispatchEvent(new FlexEvent("updateComplete")). Always do: dispatchFlexEvent("updateComplete"). 10x performance increase.
Please consider integrating this immediately. It works, it's not complicated, and it greatly improves performance. It's like static vs. dynamic objects, you 99% of the time should TYPE your objects for compile-time checking. Same with this, 99% of the time you want to make sure it's necessary to dispatch an event before you go about creating it.
Once this is integrated into the UIComponent, the same thing should be done to GraphicElement (base class for FXG classes), and some of the Managers (DragManager/LayoutManager/SystemManager) should consider implementing this stuff.
Please let me know as soon as possible your decision. I hope you can find time to integrate this in before the Production Release, as it is not an API-changer, and it doesn't change the theory behind Flex (like SkinnableComponent did). This would only take an hour to integrate max.
Thank you. I have put a lot of effort into making sure this is designed well.
Lance