Skip to content

Conversation

@ttypic
Copy link
Contributor

@ttypic ttypic commented Aug 20, 2025

Add rules for Gson serializers and reflection used during plugin initialization.

Summary by CodeRabbit

  • Bug Fixes

    • Ensures Objects plugin and related serializers are preserved in Android builds, preventing potential runtime issues when code is minified/obfuscated.
  • Chores

    • Updated Android obfuscation rules to align with current components, removing outdated keep directives and adding targeted ones for Objects support, improving build reliability and potentially reducing app size.

Add rules for Gson serializers and reflection used during plugin initialization.
@coderabbitai
Copy link

coderabbitai bot commented Aug 20, 2025

Walkthrough

Updated ProGuard rules in android/proguard.txt: removed keep rules for WebSocketTransport$Factory and io.ably.lib.types.**; added keep rules for Objects plugin and serializers (ObjectsPlugin, *Serializer, ObjectsJsonSerializer). Other existing keep/dontwarn directives remain unchanged.

Changes

Cohort / File(s) Summary
ProGuard config updates
android/proguard.txt
Removed keep rules for io.ably.lib.transport.WebSocketTransport$Factory and io.ably.lib.types.**. Added keep rules for io.ably.lib.objects.*ObjectsPlugin, io.ably.lib.objects.serialization.*Serializer, and io.ably.lib.objects.ObjectsJsonSerializer. Preserved existing rules and dontwarn directives.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through rules with whiskers keen,
Snipping keeps where none are seen.
New serializers, plugins too—
I tuck them safe, just for you.
In the grass of bytes I play,
Obfuscation kept at bay. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/proguard-rules

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
android/proguard.txt (3)

7-13: Consider preserving type information used by Gson TypeToken and annotations

If you rely on Gson TypeToken or runtime annotations, you typically need to keep Signature and runtime annotations. If these are not already preserved elsewhere in the build, add:

 -keep class org.msgpack.core.** {*;}
 -keepclasseswithmembers class io.ably.lib.rest.Auth** {*;}
 -keep class com.google.gson.** {*;}
 -dontwarn org.msgpack.core.buffer.**
 -dontwarn org.slf4j.**
 -dontwarn lombok.**
+
+# Preserve generic signatures and runtime annotations for Gson/TypeToken
+-keepattributes Signature,RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleAnnotations

Please confirm if these attributes are already kept in another proguard/r8 config (app module or consumer rules). If so, this addition may be unnecessary.


2-2: Re-evaluate the blanket keep for io.ably.lib.types. to minimize APK size**

If removal was intended, it’s currently still present. Keeping the entire types package can significantly reduce shrinking/obfuscation benefits. If Gson serialization for types is annotation-driven (@SerializedName) or uses explicit TypeAdapters, you can likely narrow this rule to only the reflective entry points.

Use the script in the first comment to:

  • Confirm whether fields in io.ably.lib.types.* rely on Gson’s default naming (risk if obfuscated).
  • Identify any TypeAdapters for these types.
  • If safe, replace with narrower rules (e.g., keep only types with runtime reflection and the specific adapters).

3-5: Current ProGuard rules sufficient for ObjectsPlugin and Serializer

The default plugin and serializer are loaded via Class.forName(“io.ably.lib.objects.DefaultObjectsPlugin”) and Class.forName(“…DefaultObjectsSerializer”), both of which match your existing *ObjectsPlugin and *Serializer suffix keep rules. No additional keep rules are required at present.

If you introduce new plugin or adapter classes that do not follow these naming conventions, you can optionally add interface-based keep rules for future-proofing:

-keep class ** implements io.ably.lib.objects.ObjectsPlugin { *; }
-keep class io.ably.lib.objects.serialization.** implements com.google.gson.JsonSerializer { *; }
-keep class io.ably.lib.objects.serialization.** implements com.google.gson.JsonDeserializer { *; }
-keep class io.ably.lib.objects.serialization.** extends com.google.gson.TypeAdapter { *; }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6a601bb and 919dea3.

📒 Files selected for processing (1)
  • android/proguard.txt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: check
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check-liveobjects
  • GitHub Check: check (24)
  • GitHub Check: check-rest
  • GitHub Check: check (21)
  • GitHub Check: check (29)
  • GitHub Check: check (19)
  • GitHub Check: check-realtime
  • GitHub Check: build
🔇 Additional comments (2)
android/proguard.txt (2)

9-9: LGTM: keeping Gson library classes

Keeping Gson is standard for avoiding stripped internals in R8/ProGuard setups and aligns with your serializer/reflection changes.


1-2: Inconsistent ProGuard changes: keep rules still present

The PR summary indicates that the following rules were removed, but they remain in android/proguard.txt (lines 1–2):

  • -keep public class io.ably.lib.transport.WebSocketTransport$Factory {*;}
  • -keep class io.ably.lib.types.** {*;}

Please confirm the intended action:

  • Should these keep rules be removed?
  • If so, verify there’s no reflective loading of WebSocketTransport.Factory (e.g., via ServiceLoader) and no Gson-based serialization of types under io.ably.lib.types that would break without them.

Copy link
Collaborator

@sacOO7 sacOO7 left a comment

Choose a reason for hiding this comment

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

LGTM

@ttypic ttypic merged commit b12fabb into main Aug 21, 2025
13 checks passed
@ttypic ttypic deleted the fix/proguard-rules branch August 21, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants