GGUI保存图片

想做一个button保存截屏,但是window会自动关闭

import taichi as ti
import time
ti.init(ti.gpu)

particles = ti.Vector.field(3, dtype=ti.f32,shape=3)
@ti.kernel
def init():
for i in range(3):
particles[i] = ti.Vector([i,i,i])
init()
window = ti.ui.Window(“Particles”, (1000,1000))
canvas = window.get_canvas()
scene = window.get_scene()
gui = window.get_gui()
camera = ti.ui.Camera()
camera.position(0,0,10)

while window.running:
camera.track_user_inputs(window, movement_speed=1.0, hold_key=ti.ui.LMB)
scene.set_camera(camera)
scene.ambient_light((0.8,0.8,0.8))
scene.point_light((0,0,5),(0,0,0))
scene.point_light((0,0,2),(0,0,0))

scene.particles(particles,color=(0.68,0.26,0.19),radius=0.2)
canvas.scene(scene)
with gui.sub_window("GUI",x=0,y=0,width=0.15,height=0.08):
    screen_shot = gui.button("Take a screenshot")
    if screen_shot:
        window.save_image('frame.png')


window.show()

就会window就会关闭,报错
[Taichi] version 1.7.0, llvm 15.0.4, commit 2fd24490, linux, python 3.11.5
[Taichi] Starting on arch=cuda
[I 02/26/24 11:43:09.786 29778] [swap_chain.cpp:dump_image_buffer@164] Dumping image buffer…
段错误 (核心已转储)