Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more than 1024 points causes the 3D viewer to crash. #932

Closed
cudmore opened this issue Jan 31, 2020 · 5 comments 路 Fixed by #934
Closed

Adding more than 1024 points causes the 3D viewer to crash. #932

cudmore opened this issue Jan 31, 2020 · 5 comments 路 Fixed by #934
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cudmore
Copy link

cudmore commented Jan 31, 2020

馃悰 Bug

Napari crashes if I add more than 1024 3D points and switch to the 3D view. It also crashes with more than 1024 points if I explicit start up Napari with the 3D view.

To Reproduce

import numpy as np
import napari

with napari.gui_qt():
	myViewer = napari.Viewer()

	# works up to 1024 points but crashes if >1024 points
	s = (1025,3)
	# (1025,3) random integers in the range [10, 100)
	myPoints = np.random.randint(10,100,s)
	pointLayer = myViewer.add_points(myPoints)
  1. Run the code above
  2. Click the 3D view button/icon
  3. Napari crashes

Environment

MacOS 10.14.3
Python 3.7.2
Napari 0.2.11

  • Please copy and paste the information at napari info option in help menubar here:

napari: 0.2.11
Platform: Darwin-18.2.0-x86_64-i386-64bit
Python: 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) [Clang 6.0 (clang-600.0.57)]
Qt: 5.13.0
PyQt5: 5.13.0
VisPy: 0.6.4
NumPy: 1.16.4
SciPy: 1.2.1
scikit-image: 0.15.0
Dask: 2.7.0

GL version: 2.1 INTEL-12.4.7
MAX_TEXTURE_SIZE: 16384

@sofroniewn sofroniewn added the bug Something isn't working label Jan 31, 2020
@sofroniewn sofroniewn added this to the 0.2.12 milestone Jan 31, 2020
@sofroniewn
Copy link
Contributor

This looks like a relatively straight forward bug with our thumbnail generation

Traceback (most recent call last):
  File "/Users/nsofroniew/GitHub/napari/napari/_qt/qt_viewer_buttons.py", line 154, in change_ndisplay
    self.viewer.dims.ndisplay = 3
  File "/Users/nsofroniew/GitHub/napari/napari/components/dims.py", line 296, in ndisplay
    self.events.ndisplay()
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/Users/nsofroniew/GitHub/napari/napari/components/viewer_model.py", line 400, in _update_layers
    layer.dims.ndisplay = self.dims.ndisplay
  File "/Users/nsofroniew/GitHub/napari/napari/components/dims.py", line 296, in ndisplay
    self.events.ndisplay()
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/Users/nsofroniew/GitHub/napari/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/Users/nsofroniew/GitHub/napari/napari/layers/base/base.py", line 383, in _update_dims
    self.refresh()
  File "/Users/nsofroniew/GitHub/napari/napari/layers/base/base.py", line 602, in refresh
    self._update_thumbnail()
  File "/Users/nsofroniew/GitHub/napari/napari/layers/points/points.py", line 1322, in _update_thumbnail
    colormapped[coords[:, 0], coords[:, 1]] = colors
ValueError: shape mismatch: value array of shape (1025,4) could not be broadcast to indexing result of shape (1024,4)

determined by our usage of a max number of points to use for thumbnail generation - https://github.com/napari/napari/blob/master/napari/layers/points/points.py#L205

@kevinyamauchi can you take on fixing this?

@cudmore
Copy link
Author

cudmore commented Jan 31, 2020

Thanks for the follow-up and link to the code. Next time I run into a bug like this I will try and take the time to fix it before posting.

@kevinyamauchi
Copy link
Contributor

Thanks for the follow-up and link to the code. Next time I run into a bug like this I will try and take the time to fix it before posting.

No worries! I really appreciate you flagging the bug. I am happy to make a fix today!

@sofroniewn
Copy link
Contributor

Next time I run into a bug like this I will try and take the time to fix it before posting.

@cudmore you're also more than welcome to post bugs right away, ask for pointers, and then try and fix them yourself - no need to struggle alone first!!

@kevinyamauchi
Copy link
Contributor

kevinyamauchi commented Feb 1, 2020

@cudmore , I just merged a fix into master (#934). Please feel free to let me know if you continue to have issues. Thank you again for bringing this to our attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants