fury icon indicating copy to clipboard operation
fury copied to clipboard

ShowManager Repeating Timer behavior and window size attribute

Open devmessias opened this issue 2 years ago • 2 comments

Hi everyone. I noticed some bugs on the ShowManager object

Timer Event

ShowManager destroy_timer method destroys the timer without removing the callback related with the observer. Thus, we lost the reference for the callback. Because of that, another timer event created after that will keep calling the callback function with the missed reference. See the code bellow,

from fury.window import ShowManager
from fury.actor import sphere
import numpy as np

repeat = False # bug appears with both options: False or True
centers = np.array([[1, 0,0]])
showm = ShowManager(size=(400, 400))
i1 = 0
i2 = 0

def t1(_, __):
    global i1
    i1 += 1
    print(f'timer 1 event {i1}')

def t2(_, __):
    global i2
    i2 += 1
    print(f'timer 2 event {i2}')

showm.initialize()
showm.add_timer_callback(repeat, 1, t1)
showm.add_timer_callback(repeat, 2, t2)

showm.destroy_timer(showm.timers[0])
color = np.array([0, 1, 0])
actor = sphere(centers ,color)
showm.scene.add(actor)

showm.start()
#showm.render()
assert i1 == 0

Size Window

This is more trickly and usually happens on Windows. The vtk creates a window instance with a slightly different size. Therefore, the following test can fail:

size = (300, 400)
showm = ShowManager(size=size)
# code goes here
assert size[0] = showm.size[0] and size[1] == showm.size[1]

I noticed that bug running the tests of PR #437 on windows github actions.

OS and pkgs

{'fury_version': '0.7.1', 'pkg_path': '/home/devmessias/phd/fury/fury',
'commit_hash': '426c15b9e4895bdba449be3c63168b5179a34202', 'sys_version': '3.8.5
(default, Sep  4 2020, 07:30:14) \n[GCC 7.3.0]', 'sys_executable':
'/home/devmessias/anaconda3/bin/python', 'sys_platform': 'linux',
'numpy_version': '1.20.3', 'scipy_version': '1.5.2', 'vtk_version': '9.0.3',
'matplotlib_version': '3.3.2', 'dipy_version': '1.4.1'}

devmessias avatar Aug 04 '21 13:08 devmessias

Hi @devmessias,

Good catch for the timer event issue !!

I can not reproduce the error on window size. Are you sure about this one?

skoudoro avatar Aug 05 '21 09:08 skoudoro

I confirm the window size bug happens on my Windows version. Vtk 9.0.3, fury from master. It seems to create a padding (maybe of the size of the titlebar). Updating the window size inside the showm as soon as the window is created may fix this issue.

filipinascimento avatar Aug 05 '21 12:08 filipinascimento