fix: gracefully fall back to base snapshot when patch loading fails#114
Closed
eseidel wants to merge 2 commits intoshorebird/devfrom
Closed
fix: gracefully fall back to base snapshot when patch loading fails#114eseidel wants to merge 2 commits intoshorebird/devfrom
eseidel wants to merge 2 commits intoshorebird/devfrom
Conversation
When a native iOS plugin (e.g., native_geofence) spawns a secondary headless FlutterEngine, TryLoadFromPatch attempts to load the patch for the secondary engine. If loading fails (e.g., due to iOS background restrictions on file access or Dart_LoadELF rejection), the previous FML_LOG(FATAL) would kill the entire process. Change the log level from FATAL to ERROR and allow the nullptr return to propagate. ResolveIsolateData/ResolveIsolateInstructions in dart_snapshot.cc already handle nullptr from TryLoadFromPatch by falling through to SearchMapping, which loads the base app snapshot. The secondary engine will run unpatched rather than crashing the app. Fixes shorebirdtech/shorebird#3634
Author
|
Closing for now — need more information from the reporter about the actual failure mode before making a fix. The ERROR logs from PatchCacheEntry::Create (lines 35 and 56 of patch_cache.cc) should appear before the FATAL crash and tell us exactly why the patch load fails. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FML_LOG(FATAL)toFML_LOG(ERROR)inTryLoadFromPatchwhenPatchCache::GetOrLoadreturns nullptrResolveIsolateData/ResolveIsolateInstructionsindart_snapshot.ccto fall through toSearchMappingand load the base app snapshot instead of crashingContext
When a native iOS plugin (e.g.,
native_geofence) spawns a secondary headlessFlutterEnginefor background work,TryLoadFromPatchattempts to load the.vmcodepatch for that engine. If loading fails for any reason (iOS background file access restrictions,Dart_LoadELFrejection, etc.), theFML_LOG(FATAL)kills the entire process viafml::KillProcess().The fallback path already exists in
dart_snapshot.cc— bothResolveIsolateDataandResolveIsolateInstructionscallTryLoadFromPatchfirst, then fall through toSearchMappingif it returnsnullptr. TheFATALlog prevented this fallback from ever executing.With this fix, the secondary engine runs unpatched (using the base snapshot) rather than crashing the app.
Fixes shorebirdtech/shorebird#3634
Test plan
FlutterEnginespawned by a native plugin falls back to base snapshot instead of crashing