Skip to content

[pigeon] Provide a way to remove event channel handlers #195049

Closed
flutter/packages
#13438

Description

@stuartmorgan

Pigeon's event channel register method internally registers an event channel handler with the engine, but doesn't provide any mechanism for removing it. This means that native handlers for channels that have a shorter lifespan than the engine (e.g., video_player player instances) will accumulate over time.

I think the simplest solution, and the one that is consistent with other Pigeon registration APIs, is to just make the handler parameter nullable, and handle nulls as setting a nil handler for that channel on the engine. It shouldn't be necessary to save the actual underlying event channel object for re-use, because internally it's just a name-based binding on the engine itself that's just mediated by the channel object.

This applies to both the Kotlin and Swift generators.

Activity

  1. added
    platform-androidAndroid applications specifically
    platform-iosiOS applications specifically
    packageflutter/packages repository. See also p: labels.
    p: pigeonrelated to pigeon messaging codegen tool
    on Oct 22, 2026
  2. stuartmorgan commented on Oct 24, 2026

    @stuartmorgan
    ContributorAuthor

    It shouldn't be necessary to save the actual underlying event channel object for re-use, because internally it's just a name-based binding on the engine itself that's just mediated by the channel object.

    Apparently on iOS/macOS at least, this is no longer true. I'm pretty sure it was originally, but now there's an identifier owned by the event channel instance that's used for unregistering, so this will require a different approach.

  3. self-assigned this
    on Oct 25, 2026
  4. added
    P1High-priority issues at the top of the work list
    on Oct 27, 2026
  5. github-actions commented on Nov 13, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyplatform-iosiOS applications specificallyteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions