-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I implemented this in flutter/engine#21062 (reverted in flutter/engine#21391) but it broke google3 because, to quote @jason-simmons :
When
setMessageHandlercallsdrain, theawait nullin the patch provides an opportunity for a deferredsetMessageHandler(channel, null)to execute.This causes an infinite loop where the
draincallback insetMessageHandlertries to callhandlePlatformMessageon the pending messages. But the newly installed message handler was nulled out during theawaitindrain. SohandlePlatformMessagequeues that message to the channel buffer. Thedrainloop 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 anEventChanneland then immediately canceling the subscription. But the cancellation is asynchronous, and in this case the cancellation'ssetMessageHandler(channel, null)happens to run at a bad time.