I have a racket gui app that uses a canvas% with overridden on-event and on-paint methods. When the user hovers over drawn elements the on-paint is called via (send this refresh) to display the element under the cursor with a selection/outline.
Recently I noticed that this has gotten extremely slow. It seems to me this might be a difference between BC and CS, but I haven't checked with different versions in depth yet. (just from the behavior/performance I remember it had in the past) In the past a call to (send this refresh) seemed to be processed concurrently in regard to on-event. Now it seems like the first (send this refresh) eagerly triggers the on-paint and this on-paint somehow blocks the processing of on-event until the on-paint is finished, after that 1 more mouse event is processed re-triggering the on-paint. Effectively redrawing for every mouse event, causing the app to draw old uninteresting frames (because the mouse events aren't processed fast enough and only the last position is interesting for me). Currently I have implemented a workaround: (define (oneoff-timer interval thk) (new timer% [notify-callback thk] [interval interval] [just-once? #t])) (define (debounce interval thk) (define timer #f) (define (fire) (set! timer #f) (thk)) (define (trigger) (unless timer (set! timer (oneoff-timer interval fire)))) trigger) ;; within the canvas impl (define dirty! (debounce 50 (thunk (send this refresh)))) ;; within on-event calling (dirty!) instead of (send this refresh) directly ;; this effectively waits at least 50 ms before trying to refresh thus allowing most on-event ;; calls to complete before on-paint is executed the first/next time, thus only drawing the last frame or a few in-between frames if the mouse is moved for a long time I may try to construct a minimal example, but wanted to put the info out there, because the behavior seems so different from before. Tested version: Racket v8.1 [cs] linux Simon -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/9298249c-3d3d-4f1f-a18d-945ea7d1e34en%40googlegroups.com.