imagej / imagej/pyimagej

[macOS] Initializing PyImageJ before napari breaks napari

Open
#197 5 comments 0 reactions 0 assignees View on GitHub
bug macos-gui
Dominant language
Python
Stars
534
Forks
95
PR merge metrics
No merged PRs in 30d

Description

Here is a minimal example:
```python
import imagej
ij = imagej.init("2.5.0", add_legacy=False)
#-----
import napari, skimage
napari.view_image(skimage.data.cells3d())
```

The `view_image` call then fails. First we see `WARNING: no screens available, assuming 24-bit color`, and then deep in the stack trace:
```python
quartz.CGDisplayScreenSize(display)
```
returns 0, and then `ZeroDivisionError: float division by zero`

---------------------
WORKAROUND: start napari first:

```python
import napari
napari.Viewer()
#-----
import imagej
ij = imagej.init("2.5.0", add_legacy=False)
#-----
import skimage
napari.view_image(skimage.data.cells3d())
```

But I found that with the workaround, trying to change the color map caused the napari GUI to hang.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the minimal macOS example in the issue and compare it with the workaround that initializes napari first. Trace the screen-size failure around quartz.CGDisplayScreenSize and verify that napari can display the sample image and change its color map without a GUI hang.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.