I’ve run into this issue of all animations being very jerky on one machine I use for development, but not on another (both running macOS 10.13.6). While investigating this issue, I made some curious observations, which might point to a problem within Panda3D.
Generally, all types of animations (using e.g.
posInterval()) run very jerkily (uneven speed, frame rate varying wildly) independent of the complexity of the scene. I tried many, many things, including:
- Setting the frame rate of the global clock to different values.
- Putting the global clock into different modes.
- Manually calling
step()on the task manager.
- Enable/disable vertical sync.
- Running from an app created by
build_appsinstead of from the command line (macOS is known for applying magic to bundled apps).
- Trying the supplied asteroids sample project (shows the issue too).
- Rebooting the machine and using a test account without any background applications running.
- Monitoring CPU and GPU usage (both stay in the range of 1 to 3 % when running the project).
Demonstrating the Issue
To demonstrate the issue, I created a minimal example project:
The project runs a continuous animation and writes a number to the console each frame.
100 is printed, if the time between the last and this frame (
get_dt()) was exactly 1/60 of a second (my monitor is set to a refresh rate of 60 Hz). The number is lower or higher if the delay was smaller or larger, respectively. Here is a sample of its output:
203 203 222 25 149 203 197 202 200 46 108 142 57 93 152 200 203 201 198 205 52 98 142 56 101 146 200 204 52 99 99 100 144 57 100 148 200 200 53 101 94 108 141 56 151 125 172 199 201 201 199 200 202 53 99 145 59 99 148 200 198 200 202 203 197 198 203 202 199 53 100 98 101 141 60 147 133 164 202 199
As you can see, the numbers are all over the place, ranging between 50 and 200.
The machine I have this issue with has the following spec:
- 2.3 GHz Intel Core i7
- 16 GB 1600 MHz DDR3
- Intel HD Graphics 4000 1536 MB
The other machine, which does not show the issue at all, has these specs:
- 3 GHz Intel Core i7
- 16 GB 1600 MHz DDR3
- Intel Iris 1536 MB
Now to the observation. I have found three cases in which the problem completely disappears:
- Run the application full screen.
- Run another application drawing animated stuff to the screen at the same time.
- Record the screen using QuickTime Player
For the second case, I just ran the game Broken Age and let it sit on the title screen. Just playing a YouTube video in Safari or Google Chrome also works, but not in Firefox. To create the demonstration recordings below, I used the template chooser of Quartz Composer (one of the development tools for macOS), which displays an animated preview of the selected template. There I can easily switch between a template with and without animation.
I created two screen recordings which should make the issue clear. One uses the asteroids sample project, the other uses the example project linked above.
- Video 1: https://www.youtube.com/watch?v=5HIWjQqpT9g
- Video 2: https://www.youtube.com/watch?v=g1bmxKX-_nI
I’d like to get smooth animations with Panda3D on both of my machines! What do you suggest should I try next to narrow down the problem? Or does one of the developers what to look into this using my help?
Thank you in advance!