This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Couldn't load subscription status.
- Fork 6k
Decode empty message to nil in standard codec #25064
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
I'm fine reverting the cleanup in the iOS embedder on grounds of "if it ain't broke..." but it does simplify the logic a little and removes a branch. |
shell/platform/darwin/ios/framework/Source/platform_message_router.mm
Outdated
Show resolved
Hide resolved
stuartmorgan-g
approved these changes
Mar 18, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as is, but also changing the macOS embedding to be consistent with the iOS behavior seems reasonable.
This updates Flutter.*Codec `decode:` implementations to treat empty
messages as equivalent to nil or NSNull, which avoids a crash when we
subsequently otherwise try to read the type/value from the message. This
handles the case where the sender were to send `null` over the channel.
e.g.,
final channel = BasicMessageChannel<Object?>('somechannel', StandardMessageCodec());
channel.send(null);
It also updates the macOS embedder to send nil to the decoder when a
zero-length message is received in order to be consistent with the iOS
embedding.
Previously, the macOS embedder always encoded platform messages as
NSData regardless of length:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L498-L500
The iOS embedder did not have this issue since it special-cased
zero-length messages as nil:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/ios/framework/Source/platform_message_router.mm#L23-L26
Bug: flutter/flutter#78003
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 19, 2021
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 20, 2021
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 20, 2021
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 20, 2021
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 20, 2021
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 22, 2021
hjfreyer
pushed a commit
to hjfreyer/engine
that referenced
this pull request
Mar 22, 2021
This updates Flutter.*Codec `decode:` implementations to treat empty
messages as equivalent to nil or NSNull, which avoids a crash when we
subsequently otherwise try to read the type/value from the message. This
handles the case where the sender were to send `null` over the channel.
e.g.,
final channel = BasicMessageChannel<Object?>('somechannel', StandardMessageCodec());
channel.send(null);
It also updates the macOS embedder to send nil to the decoder when a
zero-length message is received in order to be consistent with the iOS
embedding.
Previously, the macOS embedder always encoded platform messages as
NSData regardless of length:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L498-L500
The iOS embedder did not have this issue since it special-cased
zero-length messages as nil:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/ios/framework/Source/platform_message_router.mm#L23-L26
Bug: flutter/flutter#78003
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Mar 22, 2021
chriscraws
pushed a commit
to chriscraws/engine
that referenced
this pull request
Mar 23, 2021
This updates Flutter.*Codec `decode:` implementations to treat empty
messages as equivalent to nil or NSNull, which avoids a crash when we
subsequently otherwise try to read the type/value from the message. This
handles the case where the sender were to send `null` over the channel.
e.g.,
final channel = BasicMessageChannel<Object?>('somechannel', StandardMessageCodec());
channel.send(null);
It also updates the macOS embedder to send nil to the decoder when a
zero-length message is received in order to be consistent with the iOS
embedding.
Previously, the macOS embedder always encoded platform messages as
NSData regardless of length:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L498-L500
The iOS embedder did not have this issue since it special-cased
zero-length messages as nil:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/ios/framework/Source/platform_message_router.mm#L23-L26
Bug: flutter/flutter#78003
duanqz
pushed a commit
to duanqz/engine
that referenced
this pull request
Apr 16, 2021
This updates Flutter.*Codec `decode:` implementations to treat empty
messages as equivalent to nil or NSNull, which avoids a crash when we
subsequently otherwise try to read the type/value from the message. This
handles the case where the sender were to send `null` over the channel.
e.g.,
final channel = BasicMessageChannel<Object?>('somechannel', StandardMessageCodec());
channel.send(null);
It also updates the macOS embedder to send nil to the decoder when a
zero-length message is received in order to be consistent with the iOS
embedding.
Previously, the macOS embedder always encoded platform messages as
NSData regardless of length:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L498-L500
The iOS embedder did not have this issue since it special-cased
zero-length messages as nil:
https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/ios/framework/Source/platform_message_router.mm#L23-L26
Bug: flutter/flutter#78003
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates Flutter.*Codec
decode:implementations to treat emptymessages as equivalent to nil or NSNull, which avoids a crash when we
subsequently otherwise try to read the type/value from the message. This
handles the case where the sender were to send
nullover the channel.e.g.,
It also updates the macOS embedder to send nil to the decoder when a
zero-length message is received in order to be consistent with the iOS
embedding.
Previously, the macOS embedder always encoded platform messages as
NSData regardless of length:
engine/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm
Lines 498 to 500 in ba93431
The iOS embedder did not have this issue since it special-cased
zero-length messages as nil:
engine/shell/platform/darwin/ios/framework/Source/platform_message_router.mm
Lines 23 to 26 in ba93431
Bug: flutter/flutter#78003
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.