Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log FlutterJSONMessageCodec decode errors before asserting #50163

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Jan 30, 2024

Logging JSON decode errors on assertion will help track down bugs.
flutter/flutter#100891 (comment)

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

}
NSAssert(decoded, @"Invalid JSON message, decoding failed");
NSAssert(decoded, @"Invalid JSON message, decoding failed: %@", error);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to what's already done in encode

NSAssert(encoding, @"Invalid JSON message, encoding failed: %@", error);

@@ -49,6 +49,7 @@ int main(int argc, char** argv) {
#endif // FML_OS_IOS

::testing::InitGoogleTest(&argc, argv);
GTEST_FLAG_SET(death_test_style, "threadsafe");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add this flag to allow EXPECT_EXIT.
https://github.com/google/googletest/blob/main/docs/advanced.md#death-test-styles

Otherwise:

[WARNING] ../../third_party/googletest/googletest/src/gtest-death-test.cc:1102:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 2 threads. See https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads for more explanation and suggested solutions, especially if this is the last message you see before your test times out.
../../flutter/shell/platform/darwin/common/framework/Source/flutter_codecs_unittest.mm:52: Failure
Death test: [codec encode:value]
    Result: died but not with expected error.
  Expected: contains regular expression "failed to convert to UTF8"
Actual msg:
[  DEATH   ] 2024-01-29 18:38:36.256 framework_common_unittests[31544:1799550] *** Assertion failure in -[FlutterJSONMessageCodec encode:], FlutterCodecs.mm:82
[  DEATH   ] objc[31544]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
[  DEATH   ] objc[31544]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

@jmagman jmagman marked this pull request as ready for review January 30, 2024 02:39
@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 31, 2024
@auto-submit auto-submit bot merged commit 70b9d31 into flutter:main Jan 31, 2024
28 checks passed
@jmagman jmagman deleted the json-decode-error branch January 31, 2024 17:53
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 31, 2024
…142628)

flutter/engine@9ccd81d...20e5361

2024-01-31 skia-flutter-autoroll@skia.org Roll Dart SDK from fbf1d8ebceb4 to 1f136c7b962d (1 revision) (flutter/engine#50203)
2024-01-31 magder@google.com Log FlutterJSONMessageCodec decode errors before asserting (flutter/engine#50163)
2024-01-31 mdebbar@google.com [web] Final nail in FlutterViewEmbedder's coffin (flutter/engine#49769)

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 matanl@google.com,rmistry@google.com,zra@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios platform-macos
Projects
None yet
2 participants