[Android] Fix BasicMessageChannel.resizeChannelBuffer#41982
[Android] Fix BasicMessageChannel.resizeChannelBuffer#41982auto-submit[bot] merged 2 commits intoflutter:mainfrom
Conversation
1f896f9 to
4639ff9
Compare
|
Note from android triage: @gaaclarke Do you know who might be a good reviewer for this? |
|
I don't think this is a fix. We are just swallowing an exception. |
| ByteBuffer packet = null; | ||
| try { | ||
| final String content = String.format("resize\r%s\r%d", "flutter/test", 3); | ||
| final byte[] bytes = content.getBytes("UTF-8"); | ||
| packet = ByteBuffer.allocateDirect(bytes.length); | ||
| packet.put(bytes); | ||
| } catch (UnsupportedEncodingException e) { | ||
| throw new AssertionError("UTF-8 only"); | ||
| } |
There was a problem hiding this comment.
Why is this code in the test? It's not actually contributing to the test.
There was a problem hiding this comment.
The packet variable is used below, line 47.
| } catch (UnsupportedEncodingException e) { | ||
| Log.e(TAG, "Failed to resize channel buffer named " + channel, e); | ||
| } |
There was a problem hiding this comment.
This seems to be unrelated to the bug filed upstream and intended to support channel names that aren't valid as UTF-8 strings or something. Can it just be removed or perhaps serpated out into its own PR?
There was a problem hiding this comment.
The catch is necessary because String.getBytes(charset) is declared as throws UnsupportedEncodingException
(In practice the exception will not be thrown because UTF-8 is guaranteed to be supported)
Alternatively, this could continue using Charset.forName (which does not throw any checked exceptions)
The fix here is the use of (The current Android Java/JNI platform message implementation assumes that all buffers passed to native are direct buffers) |
@chinmaygarde The fix is not to swallow an exception, it is to replace the way the The fix is to rely on Edited: Oops I just read Jason comment after posting mine 😅 |
4639ff9 to
688b0f4
Compare
|
I have updated the PR to use |
flutter/engine@bca11a4...6bc60c8 2023-05-19 [email protected] [Android] Fix BasicMessageChannel.resizeChannelBuffer (flutter/engine#41982) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
) flutter/engine@bca11a4...6bc60c8 2023-05-19 [email protected] [Android] Fix BasicMessageChannel.resizeChannelBuffer (flutter/engine#41982) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
|
FWIW, the format used for the message in this PR is deprecated, ideally we would use the binary format instead. It should be slightly more efficient. |
Description
This PR updates
BasicMessageChannel.resizeChannelBufferimplementation. Previous implementation builds a wrongByteBufferand was not tested so it is difficult to know when it stopped working.Related Issue
Fixes flutter/flutter#126632
Tests
Adds 1 test.