google-deepmind / google-deepmind/dm_control
[viewer] Importing viewer module on macos immediately kills maplotlib windows
- 主要语言
- Python
- 星标
- 4.7k
- 派生
- 764
- PR 合并指标
- 30 天内没有已合并 PR
描述
On MacOS, importing the viewer module from `dm_control` immediately kills the `matplotlib` plot figures even when it should be ideally blocked with plt.show(). To reproduce the issue run the code below as a script:
```python
import matplotlib
import matplotlib.pyplot as plt
from dm_control import viewer
if __name__ == '__main__':
print(f"Matplotlib backed {matplotlib.get_backend()} ")
plt.plot()
plt.show(block=True)
```
**NOTE** : To reproduce the bug from the above script make sure that backend used by matplotlib (printed on the terminal) is `MacOSX`. When using other non default backends on MacOS the issue goes away.
Looking into it I found that the issue comes from https://github.com/deepmind/dm_control/blob/3c67a42d021b97808fcc075c0c468d78f0c2233f/dm_control/_render/glfw_renderer.py#L28 Seems like having glfw.init() run globally is the cause.
贡献指南
调研方向
使用 matplotlib 的 MacOSX 后端通过提供的脚本重现该问题,然后检查 dm_control/_render/glfw_renderer.py 中全局 glfw.init() 调用附近的代码。确认导入时与现有 matplotlib 图形的交互,并验证导入 dm_control.viewer 不再关闭窗口。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- matplotlib, python
- 领域
- computer-graphics
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100