When does Sophix use instant hotpatching versus cold start patching?

Updated at:

The type of patch is determined by the code changes.

For minor code changes, Sophix generally applies an instant hotpatch. For major changes, such as adding new methods to existing classes or modifying .so files, a cold start patch is used. The packaging tool automatically detects the code changes to determine the patch type, so developers do not need to manage this process.

To test instant hotpatching:

  • 1. In the patch tool, do not select the force cold start option. This allows the tool to decide whether to generate a cold start patch or a hotpatch.
  • 2. Do not modify the initial startup page because loading the patch takes time.
  • 3. Try to limit changes to public classes or methods. Avoid modifying static elements.
  • 4. Changes to resources or .so files usually require a cold start to take effect.
  • 5. Use cold start patches for better stability because hotpatches may fail to load on some device models. If you use a hotpatch, test it thoroughly before publishing.

For a detailed explanation of why a patch may not take effect instantly, see the code patching chapter in the free e-book In-depth Exploration of Android Hotpatching Technology Principles.

Additionally, if Sophix detects at runtime that a device does not support instant hotpatching, it will force a cold start patch on that device.

If you require maximum stability, enable the force cold start option. This ensures all changes are packaged as a cold start patch.

Note

Cold start: The app restarts. Hotpatch: The app does not need to restart.