Skip to content

fix(privacy): Re-compile engines from cached combined rules when failing to deserialize cached engine on iOS #29369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 3, 2025

Conversation

StephenHeaps
Copy link
Collaborator

  • This change only affects the flow where we fail to deserialize the AdblockEngine using the serialized list.dat from our cache.
    • When this occurs for the standard engine, we will use instead re-compile the AdblockEngine from the cached combined rule lists stored at /Caches/engines/<engine_type>/list.txt (we combine rule lists and cache them), then re-caches the engine to the serialized DAT format.
  • This recompile comes with a small one-time performance hit (~1.2s to compile from plaintext during startup vs ~0.6s to compile from DAT on iPhone XS w/ A12 Bionic), as compiling the adblock engine from plaintext is slower than loading from serialized data file.
  • Adds a adblock debug option to 'corrupt' this cache by writing empty data file to the cache location, which causes us to fail to deserialize the engine on next launch.

Resolves brave/brave-browser#46545

  1. In the QA menu / developer options menu, open the AdBlock Debugger section, then tap Corrupt Adblock Engine DAT Caches
  2. After successful alert, restart the app (if a developer, restart with debugger attached to view console logs)
  3. (Developers only) On launch you should see Set <engine_type> (txt) in console logs to indicate the engine being compiled from txt
  4. Verify adblock engine is working as expected (ex visit a website and confirm >0 items in shields panel)
  5. Restart the app
  6. (Developers only) On launch you should see Set <engine_type> (dat) in console logs to indicate the engine being loaded from cached DAT again
  7. Verify adblock engine is working as expected (ex visit a website and confirm >0 items in shields panel)

@StephenHeaps StephenHeaps self-assigned this Jun 3, 2025
@StephenHeaps StephenHeaps added CI/skip-android Do not run CI builds for Android CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-teamcity Do not run builds in TeamCity labels Jun 3, 2025
@StephenHeaps StephenHeaps marked this pull request as ready for review June 3, 2025 17:10
@StephenHeaps StephenHeaps requested a review from a team as a code owner June 3, 2025 17:10
@StephenHeaps StephenHeaps force-pushed the bugfix/ios-adblock-engine-deserialize-failure branch from 81cb737 to bafa742 Compare June 3, 2025 20:23
@StephenHeaps StephenHeaps merged commit 77e58ab into master Jun 3, 2025
18 checks passed
@StephenHeaps StephenHeaps deleted the bugfix/ios-adblock-engine-deserialize-failure branch June 3, 2025 22:25
@github-actions github-actions bot added this to the 1.81.x - Nightly milestone Jun 3, 2025
@brave-builds
Copy link
Collaborator

Released in v1.81.44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-teamcity Do not run builds in TeamCity CI/skip-windows-x64 Do not run CI builds for Windows x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Engines not correctly recompiled when failing to deserialize engine from cache on iOS
3 participants