racket / racket/gui

macOS: Racket threads do not run while dragging a slider%

Open
#357 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
68
Forks
82
PR merge metrics
No merged PRs in 30d

Description

Re. https://github.com/Bogdanp/racket-gui-easy/issues/63#issuecomment-3225228993.

As the title says, when dragging a slider, threads other than the eventspace thread are suspended. So, the threads in this example end up not running while dragging the slider (or while initiating a drag and holding the slider):

#lang racket/gui

(define f
  (new frame%
       [label "Test"]))

(define thd
  (thread
   (lambda ()
     (let loop ()
       (println `(value ,(thread-receive)))
       (loop)))))

(define tick-thd
  (thread
   (lambda ()
     (let loop ()
       (println 'tick)
       (sleep 1)
       (loop)))))

(define timer
  (new timer%
       [notify-callback
        (lambda ()
          (println 'timer-tick))]
       [interval 1000]))

(define s
  (new slider%
       [parent f]
       [label "Test"]
       [init-value 0]
       [min-value 0]
       [max-value 100]
       [callback (lambda (self _event)
                   (thread-send thd (send self get-value)))]))

(send f show #t)

Surprisingly, the timer% doesn't run either.

As a hack, I've tried setting up a display link to post dummy events between drag start and end (the display link is necessary because changed: does not fire if you just hold the slider after dragging), but that doesn't seem to help. Probably the right solution is a run loop source in queue.rkt for the event tracking mode, but I'm not sure how to do that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided racket/gui example and reproduce the suspension while dragging a slider on macOS. Then inspect queue.rkt and the event-tracking mode behavior; the issue suggests a run loop source may be relevant. Done means non-eventspace threads and the timer continue running during slider drags.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.