Skip to content

Listener finalizer gets called early #4

@georgewsinger

Description

@georgewsinger

addListener finalizers (or more specifically: finalizers associated with their wl_listeners) get called early in hsroots, causing compositors to freeze. Here is a minimum reproducible example:

outputFrameNotify :: WlListener WlrOutput
outputFrameNotify = WlListener $ \ptrWlrOutput ->
  do now <- getTime Realtime
     putStrLn (show now)  --- <-- This pauses after a few seconds due to an early finalizer call

newOutputNotify :: WlListener WlrOutput
newOutputNotify = WlListener $ \ptrWlrOutput ->
  do let outputSignals = getOutputSignals ptrWlrOutput
     let frameSignal  = outSignalFrame outputSignals
     addListener outputFrameNotify frameSignal
     return ()

main :: IO ()
main = do displayServer <- displayCreate
          eventLoop     <- displayGetEventLoop displayServer
          ptrBackend    <- backendAutocreate displayServer

          let newOutputSignal = (backendEvtOutput $ backendGetSignals ptrBackend) :: Ptr (WlSignal WlrOutput)
          addListener newOutputNotify newOutputSignal

          backendStart ptrBackend
          displayRun displayServer
          displayDestroy displayServer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions