Skip to content

Remove protobuf dependency - #96

Open
h-sumiya wants to merge 1 commit into
yekeskin:mainfrom
h-sumiya:remove-protobuf-dependency
Open

Remove protobuf dependency#96
h-sumiya wants to merge 1 commit into
yekeskin:mainfrom
h-sumiya:remove-protobuf-dependency

Conversation

@h-sumiya

Copy link
Copy Markdown

Summary

  • Remove the protobuf dependency from both the Dart and Rust packages.
  • Replace generated protobuf messages with lightweight, purpose-built wire codecs.
  • Preserve wire compatibility with the existing bundled native libraries.
  • Remove the .proto schemas and protobuf code generation workflow.
  • Add validation for malformed input, invalid wire types, integer overflow, and truncated fields.
  • Add Dart and Rust tests covering wire compatibility and large frame payloads.

Motivation

The native bridge only exchanges five fixed message types, so using a general-purpose protobuf runtime introduced unnecessary dependency, reflection, allocation, and decoding overhead.

The new codecs implement only the wire fields required by the bridge. This keeps the existing behavior and native binary compatibility while reducing runtime overhead and removing the protobuf dependency entirely.

No new project dependencies were added.

Compatibility

The bridge wire representation remains compatible with the existing Android, iOS, macOS, Linux, and Windows native artifacts.

The existing model names, constructors, and fields remain available, so application-facing encoding and decoding APIs are unchanged.

Native compatibility was verified using the bundled Linux library for:

  • Single-frame decoding
  • Decoder initialization and disposal
  • Frame iteration and reset
  • AVIF encoding followed by decoding of the generated output

Performance

A local before-and-after benchmark using a 1 MiB frame over 200 iterations produced the following results:

Operation Before After Improvement
Encode request serialization ~475 ms ~112 ms ~4.2x faster
Frame deserialization ~121 ms ~0.5 ms Over 200x faster

The deserialization improvement primarily comes from avoiding the protobuf runtime and returning a zero-copy view of frame payloads.

Validation

  • flutter test — 5 Dart codec tests passed
  • Standalone Rust codec tests — 4 tests passed
  • dart analyze lib/models test/wire_format_test.dart — no issues
  • flutter analyze for flutter_avif_web — no issues
  • flutter analyze lib test for flutter_avif — completed with existing informational lints only
  • Native Linux decode lifecycle integration test — passed
  • Native Linux encode/decode round-trip test — passed

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.

1 participant