[ios] Avoid crashing if metadata map is missing some entries
Crashes have been reported in the wild caused by missing entries in metadata_map when calling SerializeWebStateList(...). As there is no reproduction steps, change add a workaround in SessionRestorationServiceImpl where the map is filled with the metadata for all WebState in the WebStateList. This is done by introducing WebState::SerializeMetadataToProto(...) to create the metadata from a WebState, and UpdateMetadataMap(...) which ensure that the metadata map contains items for all WebStates in the WebStateList (and only those WebStates). Call UpdateMetadataMap(...) after loading the data to purge the metadata for evicted WebStates, and just before serializing the WebStateList (to ensure there is no crash). Fixed: 332533665 Change-Id: I04eef6bbb12fc0b17fbe7f78ce6783a5038290ae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5419321 Reviewed-by:Mike Dougherty <michaeldo@chromium.org> Commit-Queue: Sylvain Defresne <sdefresne@chromium.org> Cr-Commit-Position: refs/heads/main@{#1281970}
Loading
Please register or sign in to comment