Den lør. 22. maj 2021 kl. 05.37 skrev [email protected] <
[email protected]>:

> 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).
>

I was looking at the code for racket/draw and spotted this:

    ;; The Racket BC can handle concurrent callbacks in different Racket
    ;; threads, because it copies the C stack in and out to implement
    ;; threads. The Racket CS cannot do that, so callbacks have to be
    ;; atomic. At the same time, we need some atomic callbacks to be able
    ;; to escape with an exception.

It matches your observations.

https://github.com/racket/draw/blob/master/draw-lib/racket/draw/unsafe/callback.rkt

/Jens Axel

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABefVgwx9gkphjpGeA08Z-%3DdRvTZMfEbm1B%2B6HzPmi_fWiSKgw%40mail.gmail.com.

Reply via email to