Skip to content

Dart_PostCObject doesn't communicate why it fails #64488

Open

Description

@gaaclarke

Description

When Dart_PostCObject returns false, an embedder can't tell why. Today it can fail for three different reasons:

  1. The message couldn't be serialized (WriteApiMessage returned nullptr).
  2. The destination port doesn't exist (it was closed, or its isolate exited).
  3. The VM is shutting down (PortMap::ports_ == nullptr).

Reasons 2 and 3 are normal when a reply comes back after its isolate is gone. Reason 1 is a bug in the embedder. Embedders want to handle these differently, ignoring the first two and aborting on the third, but the API returns the same bool for all three.

linked issues

flutter/flutter#189768

Proposed fixes

  1. Make a new Dart_PostCObject that returns an enum that represents the status instead of just a bool.
  2. Add a new function bool Dart_IsPortAlive(Dart_Port port_id)

Activity

  1. added
    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
    on Oct 7, 2026
  2. biggs0125 commented on Oct 7, 2026

    @biggs0125

    We can add a variant of Dart_PostCObject that indicates the status reason.

    But we cannot implement Dart_IsPortAlive as this is a synchronous query that may leak details about the port being asked about.

    How frequently are people running into this? Not sure how much bandwidth we have for this right now.

  3. gaaclarke commented on Oct 7, 2026

    @gaaclarke
    ContributorAuthor

    How frequently are people running into this? Not sure how much bandwidth we have for this right now.

    The reproduction is killing an engine that is in the process of receiving a platform channel response. I've made it not a crash in flutter and instead issued a log.

    I think we would like to have it crash if the response fails to send and we aren't in a situation where we are shutting down the engine. I'm particularly concerned about situations where messages are not delivered since that can cause deadlocks in workflows. Maybe overly concerned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions