Skip to content

Sync JSON web decoders#1028

Merged
osa1 merged 34 commits into
masterfrom
web_json_decoder
Jul 28, 2025
Merged

Sync JSON web decoders#1028
osa1 merged 34 commits into
masterfrom
web_json_decoder

Conversation

@osa1

@osa1 osa1 commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

This syncs the web JSON decoder used internally.

The new decoder uses js_interop instead of the Dart standard library to
improve performance when compiled to JS.

Benchmarks

master, JS:

protobuf_from_json_string(RunTimeRaw): 1423.134328358209 us.

PR, JS:

protobuf_from_json_string(RunTimeRaw): 971 us. 

Wasm and VM benchmarks don't change as they keep using the old implementation.

The new implementation is slower with Wasm as it does more JS interop, so we keep using the old one.

osa1 added 5 commits July 18, 2025 09:54
In preparation for adding conditional imports to be able to use
different encoding/decoding implementation based on the platform, this
PR creates an "internal" library and exports some of the important types
for encoding/decoding like `FieldInfo`, `PbFieldType` (renamed as
`PbFieldTypeInternal`).

This syncs some of cl/613649886.
@osa1 osa1 marked this pull request as ready for review July 18, 2025 09:57
@osa1 osa1 requested a review from devoncarew July 18, 2025 09:57
Base automatically changed from field_type_public to master July 23, 2025 10:15
@osa1

osa1 commented Jul 23, 2025

Copy link
Copy Markdown
Contributor Author

@devoncarew PTAL.

@devoncarew devoncarew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a few comments; but given:

This syncs the web JSON decoder used internally.

I think we can consider the code reviewed. I think my only blocking comment is that we should update the CI here to test against the vm, dart2js, and dart2wasm.

Comment thread protobuf/lib/src/protobuf/json/json_vm.dart Outdated
Comment thread protobuf/lib/src/protobuf/json/json_web.dart Outdated
Comment thread protobuf/lib/src/protobuf/json/json_web.dart
Comment thread protobuf/lib/src/protobuf/json/json_web.dart
Comment thread protobuf/lib/src/protobuf/json/json.dart
@osa1 osa1 requested a review from devoncarew July 28, 2025 10:18
@osa1

osa1 commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

@devoncarew PTAL. We should merge #1031 first, then rebase and merge this one.

@osa1 osa1 changed the title Sync web decoders Sync JSON web decoders Jul 28, 2025
@osa1 osa1 merged commit 44ecd74 into master Jul 28, 2025
11 checks passed
@osa1 osa1 deleted the web_json_decoder branch July 28, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants