-
Notifications
You must be signed in to change notification settings - Fork 362
Description
Bug Report
System Info
arcade version: Arcade 3.0.0.dev16
vendor: NVIDIA Corporation
renderer: GeForce GTX 1650/PCIe/SSE2
version: (3, 3)
python: 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
platform: win32
pyglet version: 2.0.5
PIL version: 9.4.0
Actual behavior:
In GUI of latest 3.0.0 versions, if a text goes beyond UIFlatButton width, and that button is on either UIBoxLayout or UIAnchorLayout, then app is severely slowed down.
Expected behavior:
Of course, text going beyond button width is an app side bug itself, but it shouldn't be punished by slower updates as well?
Might it be that I'm just using new GUI (I switched from 2.6.17) incorrectly?
Steps to reproduce/example code:
For example take a look at this code, which I took from (#1482) and modified.
import arcade
from arcade import Window
from arcade.gui import UIManager
class MyWindow(Window):
def __init__(self):
super().__init__()
self.manager = UIManager()
self.manager.enable()
self.set_update_rate(1/120.0)
self.button = arcade.gui.UIFlatButton(text='test',)
box = arcade.gui.UIBoxLayout()
box.add(self.button)
self.manager.add(box)
# anchor = arcade.gui.UIAnchorLayout()
# anchor.add(self.button)
# self.manager.add(anchor)
self.frame_counter = 0
def on_update(self, delta_time: float):
self.frame_counter += 1
if self.frame_counter % 60 == 0:
print(f'frame {self.frame_counter}, delta time: {delta_time}')
if self.frame_counter == 60 * 3:
print(f'text changed to a long string at frame {self.frame_counter}')
self.button.text = 'test' * 100
if self.frame_counter == 60 * 5:
arcade.exit()
def on_draw(self):
arcade.start_render()
self.manager.draw()
if __name__ == '__main__':
MyWindow().run()It produces following output:
frame 60, delta time: 0.008671300000000048
frame 120, delta time: 0.00833370000000011
frame 180, delta time: 0.008338000000000179
text changed to a long string at frame 180
frame 240, delta time: 0.03393580000000007
frame 300, delta time: 0.03376399999999968
Notice delta time increase after text was changed.
The farther text goes beyond the edge of a button, the higher delta time increases.
If we set width so that button covers whole text all the time:
self.button = arcade.gui.UIFlatButton(text='test', width=10000)Delta time won't change obviously:
frame 60, delta time: 0.008335700000000168
frame 120, delta time: 0.008378600000000347
frame 180, delta time: 0.008336700000000086
text changed to a long string at frame 180
frame 240, delta time: 0.008465799999999746
frame 300, delta time: 0.00833459999999997