Skip to content

Keep protobuf's parseFrom so the GroupUpdated serialization fix survives the shrinker - #2224

Merged
mpretty-cyro merged 1 commit into
devfrom
fix/protobuf-parsefrom-keep-rule
Sep 28, 2026
Merged

mpretty-cyro merged 1 commit into
devfrom
fix/protobuf-parsefrom-keep-rule

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

Follow-up to #2211, which is already on dev: the fix it landed does nothing in a build that ships.

JobKryo's serializer rebuilds a protobuf through parseFrom, reached reflectively, so R8 cannot see the call. On a minified build (qa inherits release's isMinifyEnabled), R8's own removal list contained:

app/build/outputs/mapping/playQa/usage.txt
    public static org.session.protos.SessionProtos$GroupUpdateMessage parseFrom(byte[])

— along with 62 other protobuf parseFrom(byte[]) overloads. -dontobfuscate keeps the names, which is what makes this look safe, but shrinking still removes the method. The read would throw NoSuchMethodException, be caught where the KryoException was caught, and drop the row exactly as before the fix. Unit tests cannot see it because they are not minified.

Changes

  • A keep rule for parseFrom(byte[]) on protobuf message classes, next to the existing Kryo section that keeps Destination$* constructors for the same underlying reason.
  • JobKryoTest gains a round trip through the job's own serialize() / Factory.create() pair rather than the shared Kryo alone — reverting either direction to a bare Kryo() now fails it, which the previous test did not catch.

Verification

Re-ran :app:minifyPlayQaWithR8 on this branch: no org.session.protos parseFrom(byte[]) appears in usage.txt (63 protobuf ones before the rule, 7 after, all of them DataStore's repackaged protobuf and UnknownFieldSet, none of which we parse through), and SessionProtos$GroupUpdateMessage parseFrom(byte[]) is listed in seeds.txt as kept. Full unit suite: 312/312.

The serializer rebuilds a protobuf through parseFrom, reached reflectively, so
R8 cannot see the call: usage.txt for a minified build listed
SessionProtos$GroupUpdateMessage.parseFrom(byte[]) among the removed methods,
along with 62 other protobuf parseFrom overloads. The read would have thrown
NoSuchMethodException, been caught where the KryoException was caught, and
dropped the row exactly as before -- so the fix was inert in every build that
ships, and no JVM test could see it because unit tests are not minified.

With the rule, none of the parseFrom(byte[]) methods on org.session.protos are
removed and the kept seed is listed for the ones we parse.

The new test covers the job's own serialize/create pair rather than the shared
Kryo alone, so reverting either direction to a bare Kryo fails it.
@mpretty-cyro
mpretty-cyro marked this pull request as ready for review September 28, 2026 04:32
@mpretty-cyro
mpretty-cyro merged commit b0d8078 into dev Sep 28, 2026
5 checks passed
@mpretty-cyro
mpretty-cyro deleted the fix/protobuf-parsefrom-keep-rule branch September 28, 2026 04:32
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