Skip to content

dart:ui ChannelBuffers.drain should be async #66699

@Hixie

Description

@Hixie

I implemented this in flutter/engine#21062 (reverted in flutter/engine#21391) but it broke google3 because, to quote @jason-simmons :

When setMessageHandler calls drain, the await null in the patch provides an opportunity for a deferred setMessageHandler(channel, null) to execute.

This causes an infinite loop where the drain callback in setMessageHandler tries to call handlePlatformMessage on the pending messages. But the newly installed message handler was nulled out during the await in drain. So handlePlatformMessage queues that message to the channel buffer. The drain loop then dequeues the message from the channel buffer and invokes the callback again, continuing the loop.

The setMessageHandler(channel, null) task is pending because their test infrastructure is subscribing to an EventChannel and then immediately canceling the subscription. But the cancellation is asynchronous, and in this case the cancellation's setMessageHandler(channel, null) happens to run at a bad time.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions