Flex:初始化和创建完成之间间隔六秒
我正在使用大型 Flex 应用程序,我注意到我们最大的组件之一(具有大量子画布)在初始化和创建完成事件之间大约需要 6 秒。我一直在做一些阅读,发现有很多嵌套画布会导致速度减慢,但我不确定这是否是速度减慢的地方?有人对加快速度有什么建议,甚至可以准确诊断速度减慢的原因吗?
I'm working with a large flex applications and I have noticed that one of our largest components (with lots of child canvases) takes about 6 seconds between the initialize and creationComplete events. I've been doing some reading and have found that having lots of nested canvases can cause slowdowns, but i'm not sure if this is where the slowdowns would be? Anyone have any suggestions on speeding this up, or even diagnosing exactly where the slowdowns are coming from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,具有动态大小调整的嵌套容器是此类滞后的最常见原因。需要尝试的一些事情:
尽可能为容器/组件设置明确的尺寸/位置。这减少了创建过程中框架内进行的大量测量。
减少嵌套容器的数量。听起来很明显,但令人惊讶的是,当您开始批判性地审视 UI 的设置方式时,您可以削减多少内容。具体来说,是否可以通过简单地为子组件设置显式位置/大小来摆脱 HBox 和 VBox 容器?您真的需要使用表单容器吗?
尽可能将您的容器切换到更轻的 Spark Group,而不是使用更重的 Canvas。
希望有帮助。如果没有,请发布一些代码,以便我们可以深入研究您的特定问题。
It's been my experience that nested containers with dynamic sizing are the most common cause of these types of lags. Some things to try:
Set explicit sizes/positions for your containers/components whenever possible. This reduces the incredible amount of measuring that goes on within the framework during the creation process.
Reduce the number of nested containers. Sounds obvious, but it's amazing how much you can cut away when you start looking critically at how your UI is set up. Specifically, are there HBox and VBox containers you can get rid of by simply setting explicit positions/sizes for the child components? Do you really need to use a Form container?
Switch your containers to the much lighter weight Spark Groups instead of using the heavier weight Canvas where possible.
Hope that helps. If not, post some code so we can dig in to your particular issue.
最需要考虑的事情是使用 VBox 和/或 HBox 来代替一些动态生成的 x 和 y。 VBox 和 HBox 效率更高。调查一下!
The biggest thing to consider is to use VBox's and/or HBox's in place of some dynamically generated x's and y's. VBox and HBox are much more efficient. Look into it!
一次将许多显示对象添加到显示列表可能需要很长时间,特别是当我们谈论混合了布局和滚动逻辑的 Flex 容器时。既然您说您正在使用许多 Canvas 容器,那么这肯定是您遇到的问题。
我知道很多开发人员滥用
creationPolicy
属性。通常,它设置为“auto”,这允许 Flex 将容器子级的实例化推迟到“稍后”很短的时间。通常,在下一帧之前,因此您甚至看不到差异。您是否碰巧在该层次结构中的任何位置将creationPolicy
设置为"all"
?这可能会迫使画布及其子元素立即创建。Adding many display objects to the display list all at once can take a long time, especially if we're talking about Flex containers that have layout and scrolling logic in the mix. Since you say you're using many Canvas containers, that could certainly be the issue you're running into.
I know that a lot of developers abuse the
creationPolicy
property. Normally, it is set to"auto"
which allows Flex to defer instantiation of a container's children until a very short time "later". Often, before the next frame, so you don't even see the difference. Do you happen to setcreationPolicy
to"all"
anywhere in that hierarchy? This could be forcing the Canvases and their children to be created immediately.