fury
fury copied to clipboard
Multithreading support and examples
These examples illustrate how to interact with fury using two different threads.
Offscreen example uses the main thread to render the scene, while a second thread keeps saving a snapshot at random intervals.
The other example opens a window in the main thread and updates the scene form a second thread.
Note that the iren
loop had to be done manually (showm.start()
will not work in this case).
This is a work in progress PR.
Hello @filipinascimento! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:
Comment last updated at 2022-06-12 04:53:08 UTC
Codecov Report
Merging #502 (e7263d7) into master (add8cc0) will decrease coverage by
0.02%
. The diff coverage isn/a
.
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
- Coverage 87.95% 87.92% -0.03%
==========================================
Files 62 63 +1
Lines 13030 13201 +171
Branches 1308 1330 +22
==========================================
+ Hits 11460 11607 +147
- Misses 1198 1212 +14
- Partials 372 382 +10
Impacted Files | Coverage Δ | |
---|---|---|
fury/fury/window.py | 82.32% <0.00%> (-0.89%) |
:arrow_down: |
fury/fury/actor.py | 88.28% <0.00%> (-0.39%) |
:arrow_down: |
fury/fury/tests/test_actors.py | 91.40% <0.00%> (-0.27%) |
:arrow_down: |
fury/fury/material.py | 74.60% <0.00%> (ø) |
|
fury/fury/actors/peak.py | 94.25% <0.00%> (ø) |
|
fury/fury/tests/test_thread.py | 91.42% <0.00%> (ø) |
|
fury/fury/shaders/tests/test_base.py | 93.08% <0.00%> (+0.03%) |
:arrow_up: |
fury/fury/shaders/base.py | 92.92% <0.00%> (+0.14%) |
:arrow_up: |
fury/fury/utils.py | 91.89% <0.00%> (+0.22%) |
:arrow_up: |
fury/fury/tests/test_utils.py | 94.74% <0.00%> (+0.47%) |
:arrow_up: |
@filipinascimento the CI fails are not relevant to your code. Can you remove all unrelated or old examples from this PR?
Ping @filipinascimento ! It would be great to have this merged asap. Please make the required changes.
I'm having some trouble with the test on the mac. It seems like something from vtk is running in another thread. The problem seems to be caused because snapshot is being called outside of the main thread. I have an example of offscreen rendering that works so I'm figuring it out what is different.
On Feb 9, 2022, at 1:06 PM, Eleftherios Garyfallidis @.***> wrote:
Ping @filipinascimento https://github.com/filipinascimento ! It would be great to have this merged asap. Please make the required changes.
— Reply to this email directly, view it on GitHub https://github.com/fury-gl/fury/pull/502#issuecomment-1034048454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESXHJMYFTHKBN2REPVLMDU2KUKZANCNFSM5EVIRVKQ. You are receiving this because you were mentioned.
Ping @filipinascimento !!! Let's get this PR to move forward! TY!
Hi @filipinascimento,
See below for some comments. The tests are failing on macOS but it works on my local machine. We need to figure out what is the issue. the error is
illegal instruction 4
which is usually due to an architecture issue. The operating system in our CIs is macOS 11.6.5 with:
- Included Software: https://github.com/actions/virtual-environments/blob/macOS-11/20220508.1/images/macos/macos-11-Readme.md
- Image Release: https://github.com/actions/virtual-environments/releases/tag/macOS-11%2F20220508.1 maybe you can try via a virtual machine.
Thank you in advance for your feedback
Not sure how to address this problem. It happens in the threading.py when calling thread.run(), maybe related to https://github.com/tqdm/tqdm/issues/1037 . I'm not sure why threading.py would have any illegal instructions, unless that macOS VM runs in unsupported CPU microarchitecture. It is not clear which CPU model they are using in the macOS VMs.
Edit: My mistake, the problem is happening when snapshot is being called from another thread. Need more time to investigate the issue. Problem is that I have no access to an intel mac to test the macOS VM.
Hello @filipinascimento,
About the FPS issue not being accurate while using threads, it's as we suspected an OS related problem.
Linux kernels have minimal sleep interval down to 1ms. But it's higher in windows (14ms).
This got fixed in Python 3.11 and the time.sleep()
has the same accuracy regarding the OS, but since we need to maintain older versions and I think VTK is yet to be ported to python 3.11, we really can't make use of that.
A way to fix this for Windows so is setting the minimum timer resolution to 1ms:
import ctypes
import sys
if sys.platform == 'win32' and sys.version_info[1] < 11:
winmm = ctypes.WinDLL('winmm')
winmm.timeBeginPeriod(1)
This fixed the problem for me.
Hello @filipinascimento, About the FPS issue not being accurate while using threads, it's as we suspected an OS related problem. Linux kernels have minimal sleep interval down to 1ms. But it's higher in windows (14ms). This got fixed in Python 3.11 and the
time.sleep()
has the same accuracy regarding the OS, but since we need to maintain older versions and I think VTK is yet to be ported to python 3.11, we really can't make use of that. A way to fix this for Windows so is setting the minimum timer resolution to 1ms:import ctypes import sys if sys.platform == 'win32' and sys.version_info[1] < 11: winmm = ctypes.WinDLL('winmm') winmm.timeBeginPeriod(1)
This fixed the problem for me.
Thanks, this may work as a temporary solution.