Image draw performance decline between 3.1 and 3.2 for large image scroll and pan

I have an application that I am upgrading from Matplotlib 2.2.2 to Matplotlib 3.8. The application displays an image that is typically between 500Mb and 1Gb and allows the user to scroll and pan around the image. I have seen a significant decline in canvas.draw() performance with the upgrade. I have prepared a minimum working example to illustrate the issue and have used it to trace the change as having occurred between Matplotlib 3.1 and Matplotlib 3.2. The sample code follows:

import cProfile
from profilehooks import profile
import tkinter as tk
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_tkagg import (FigureCanvas)
from PIL import Image
import time

class Application(tk.Frame):

        SIZE = 16000

        def __init__(self, master=None):
            
            super().__init__(master)
            self.figure = plt.figure('Diagram')
            self.canvas = FigureCanvas(self.figure, self)
            self.ax = plt.axes()
            self.canvas.mpl_connect('button_press_event', self.toggle)
            
            self.border = 0
            random_image = self.image_gen()
            self.image = self.ax.imshow(random_image)
                 
            self.canvas.get_tk_widget().pack(side=tk.TOP,fill=tk.BOTH, expand=1)
            self.pack(side=tk.TOP,fill=tk.BOTH, expand=1)

        @profile(immediate=True)
        def toggle(self, event):
            self.border = 0 if self.border == Application.SIZE /4 else Application.SIZE /4 
            self.ax.set_xlim(self.border, Application.SIZE - self.border)
            self.ax.set_ylim(self.border, Application.SIZE - self.border)
            t1= time.process_time()
            self.canvas.draw()
            print("Draw time:", time.process_time() - t1)

        def image_gen(self):
            arr = np.zeros((100,100),dtype=int)
            arr[::2,::2] = 1
            arr[1::2,1::2] = 1
            im = Image.fromarray(np.uint8(arr))
            return im.resize((Application.SIZE, Application.SIZE))
                      
if __name__ == '__main__':
          
    root = tk.Tk()
    app = Application(master=root)
    root.state('zoomed')
    app.mainloop()

When I execute this code and click to toggle the display with Matplotlib 3.1, I see times in the 2 second range. With 3.2, this jumps to 6 seconds. 3.8 brings it back down around 4 seconds, but still twice as slow as on 3.1. Results on different machines will, I expect, vary.

The issue seems to arise in the _image.resample code but despite best efforts to dig deeper into the transformer classes, I can not see what might have changed to give rise to this issue.

Any suggestions appreciated. Ideally I would like to see 3.8 able to perform at close to the same level as 3.1 for large image pan and scroll

I think this was reported here:

Yes. Same issue raised on discourse before deciding it warranted filing as an issue. Thanks for your response and the pending PR.