Moving GPencil frames in time with Python causes viewport issues
As Antonio Vasquez suggested me : &quot;The frame number is not designed to be used in this way. The correct way to do this is to replace the strokes or replace the entire frame, but not just change the frame number. There are many things that happen under the hood and they cannot be changed as easily as it seems.&quot;
So here i am, trying to create a function moving frames by copying his strokes and points. As there are no stroke.copy() neither points.copy() methods, the function is longer than expected.
import bpy

def move_GPframe(layer, frame, frame_number):
    ### move Gpencil frames in a proper way
    #First check if there's already a frame at frame_number (and remove it)
    for _frame in layer.frames :
        if _frame.frame_number == frame_number :
            layer.frames.remove(_frame)
    
    #create destination frame
    new_frame = layer.frames.new(frame_number)
    for stroke in frame.strokes :
        #create strokes
        new_stroke = new_frame.strokes.new()
        for attr in dir(stroke):
            try :
                #copy attributes
                setattr(new_stroke, attr, getattr(stroke, attr))
            except AttributeError: 
                pass
        
        #create points
        new_stroke.points.add(count = len(stroke.points)) 
        for i, point in enumerate(stroke.points) :
            new_point = new_stroke.points[i]
            for attr in dir(stroke):
                try :
                    #copy attributes
                    setattr(new_point, attr, getattr(point, attr))
                except AttributeError: 
                    pass
    #remove source frame
    layer.frames.remove(frame)
    return new_frame


######

ob = bpy.context.object
gp_ob = ob.data.id_data


#it gets the frames at time 1 and 10
for layer in gp_ob.layers :
    for frame in layer.frames :
        if frame.frame_number == 1 :
            frame_1 = frame #should be layer.frames[0]
        if frame.frame_number == 10 :
            frame_10 = frame #should be layer.frames[1]
            
    ## old way to do :
    #frame_1.frame_number = 10
    #frame_10.frame_number = 1
    
    ## proper way :
    frame_1 = move_GPframe(layer, frame_1, 0)#need to move the frame_1 at time 0, or it will overwrite frame_10
    frame_10 = move_GPframe(layer, frame_1, 1)
    frame_1 = move_GPframe(layer, frame_1, 10)

I feel that it can be really simplified, but at least it works.
Any suggestions ?