是什么让 JavaFx 1.2 场景图刷新?

发布于 2024-08-04 04:06:04 字数 442 浏览 11 评论 0原文

我的第一个问题=)。我正在编写一个视频游戏,其用户界面是用 JavaFx 编写的。行为是正确的,但我遇到了性能问题。我试图弄清楚如何找出正在排队刷新的内容,这些刷新会减慢应用程序的速度。

我有一个相对复杂的场景图,代表六角形地图。它可以缩放,以便地图中可以有 100 或 1000 个六边形。随着六边形数量的增加,GUI 的响应能力会降低。我使用 YourKit(一个 Java Profiler)来跟踪主要重绘操作的​​延迟。

我花了大半夜的时间试图弄清楚如何做两件事并理解一件事:

1)让 CustomNode 在绘制时将某些内容打印到控制台。这将帮助我准确识别这些油漆何时排队。

2) 识别何时将 CustomNode 放入重绘队列中。

如果我回答 1 和 2,我也许能够弄清楚是什么将所有这些不同的节点绑定在一起。 JavaFX 是否有可能只能通过全局刷新才能工作(值得怀疑)?

My first question =). I'm writing a video game with a user interface written in JavaFx. The behavior is correct, but I'm having performance problems. I'm trying to figure out how to figure out what is queuing up the refreshes which are slowing down the app.

I've got a relatively complex Scene Graph that represents a hexagonal map. It scales so that you could have 100 or a 1000 hexagons in the map. As the number of hexagons grow the responsiveness of the gui decreases. I've used YourKit (a Java Profiler) to trace these delays to major redraw operations.

I've spent most of the night trying to figure out how to do two things and understand one thing:

1) Cause a CustomNode to print something to the console whenever it is painted. This would help me identify exactly when these paints are being queued.

2) Identify when a CustomNode is put on the repaint queued.

If I answered 1 and 2, I might be able to figure out what it is that is binding all these different nodes together. Is it possible that JavaFX only works through global refreshes (doubtful)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

著墨染雨君画夕 2024-08-11 04:06:04

JavaFX 脚本是一种功能强大的 UI 语言,但某些做法会降低性能。最佳性能通常归结为:

  • 保持场景图较小

  • 将绑定的使用保持在最低限度(您可以考虑使用性能更高的触发器)

Jim Weaver 的博客文章 扩展了这些观点。

我不确定你的问题的具体答案。如果您检查 1.2.1 文档,您可能能够在 Node 文档中找到可以覆盖并添加 println 语句的点,但我不确定是否可以做到。您可以尝试在 forums.sun.com 上发帖

JavaFX script is a powerful UI language but certain practices will kill performance. Best performance generally boils down to:

  • keeping the Scene Graph small

  • keeping use of bind to a minimum (you can look at using triggers instead which are more performant)

This blog post by Jim Weaver expands these points.

I'm not sure as to the specific answers to your questions. If you examine the 1.2.1 docs you might be able to find a point in the Node documentation that you can override and add println statements but I'm not sure it can be done. You could try posting on forums.sun.com

过度放纵 2024-08-11 04:06:04

这是部分帖子。我希望在完成更多工作后对其进行扩展。我想把我迄今为止所做的事情写下来,这样我就不会忘记。

我意识到我需要让我的 IDE 在 JavaFx 1.2 源代码的完整支持下运行。这将允许我在核心代码中放置断点来弄清楚发生了什么。我决定在 Eclipse 上进行此配置,以实现远程调试。我正在 Netbeans 中开发 FX,但我更喜欢 Eclipse,所以如果可以的话,我想在其中进行调试。

为了将此信息输入 Eclipse,我首先使用我的代码使用的 Java 源代码创建了一个项目。然后我将外部 Jars 添加到项目中。在我的 Mac 上,我链接到的 Jars 位于 /Library/Frameworks/JavaFX.framework/Versions/1.2

然后我去搜索链接到这些 Jars 的源。不幸的是,它不可用。我可以在 /Library/Frameworks/JavaFX.framework/Versions/1.2/src.zip 中找到其中一些内容。

我做了一些研究,发现唯一可用的选项是安装 Java 反编译器。我使用这个是因为它很容易安装到 Eclipse 3.4 中: http colon_ //java dot decompiler _dot free.fr/ (<-- 请原谅伪链接,我的能力有限,因为我我是新人)

这就是我现在所在的地方。我可以导航到核心外汇课程,并相信我将能够设置断点并开始真正的分析。随着我的进展,我会更新这篇文章。

我发现了一个有用的基准测试工具:

如果您使用 JVM 参数运行:

-Djava.util.logging.config.file=/path/to/logging/file/logging.properties

并且您已将以下参数放入引用的文件中通过该参数:

handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.sun.scenario.animation.fps.level = ALL

您将获得控制台输出,其中包括每秒的帧数。对于 FX 1.2,它不适合我,但它似乎适用于 1.2.1(2009 年 9 月 9 日发布)。我还没有运行 1.2.1 的 Netbeans。

This is a partial post. I expect to expand it after I've done some more work. I wanted to put in what I've done to date so I don't forget.

I realized that I'd need to get my IDE running with a full compliment of the JavaFx 1.2 source. This would allow me to put break points into the core code to figure out what is going on. I decided to do this configuration on Eclipse for remote debugging. I'm developing my FX in Netbeans but am more comfortable with Eclipse so that's what I want to debug in if I can.

To get this info into Eclipse, I first made a project with the Java source that my code uses. I then added external Jars to the project. On my Mac, the Jars I linked to were in /Library/Frameworks/JavaFX.framework/Versions/1.2

Then I went searching for the Source to link to these Jars. Unfortunately, it's not available. I could find some of it in /Library/Frameworks/JavaFX.framework/Versions/1.2/src.zip.

I did some research and found that the only available option left was to install a Java Decompilier. I used this one because it was easy to install into Eclipse 3.4: http colon_ //java dot decompiler _dot free.fr/ (<-- Please forgive the psudo link, I'm limited because I'm new)

This is where I am now. I can navigate into the Core FX classes and believe I'll be able to set break points and begin real analysis. I'll update this post as I progress.

I found a helpful benchmarking tool:

If you run with the JVM arg:

-Djava.util.logging.config.file=/path/to/logging/file/logging.properties

And you've put the following args into the file referenced by that arg:

handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.sun.scenario.animation.fps.level = ALL

You'll get console output that includes your frame count per second. For FX 1.2 it wasn't working for me, but it appears to be working for 1.2.1 (which was released Sept. 9, 2009.) I don't have a Netbeans that runs 1.2.1 yet.

梦行七里 2024-08-11 04:06:04

您可能想阅读这篇文章。

http://fxexperience.com/2009/09/performance-improving-insertion -times/

基本上,场景图中的插入速度很慢,通过批量插入可以看到好处

You may want to read this article.

http://fxexperience.com/2009/09/performance-improving-insertion-times/

Basically, insertions in to the scenegraph are slow and benefits can be seen by batching up inserts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文