From 62c0bd6627507529cb43505b4da830b1d2866377 Mon Sep 17 00:00:00 2001 From: Sim Sun Date: Thu, 4 Nov 2021 00:57:17 -0700 Subject: [PATCH] Catch the SyncFailedException gracefully to avoid insta-crash in Application Summary: There're a lot of reports from github saying soloader caused insta-crash on app startup in Android 12. Catching the SyncFailedException gracefully to avoid insta-crash in Application https://github.com/facebook/SoLoader/issues/80 Fix #80 Reviewed By: charles011 Differential Revision: D32164174 fbshipit-source-id: ee5b85c1b555d318a0d720020d4e25f6135503cb --- java/com/facebook/soloader/UnpackingSoSource.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java/com/facebook/soloader/UnpackingSoSource.java b/java/com/facebook/soloader/UnpackingSoSource.java index 4c228eb..99e6d08 100644 --- a/java/com/facebook/soloader/UnpackingSoSource.java +++ b/java/com/facebook/soloader/UnpackingSoSource.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; +import java.io.SyncFailedException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -223,6 +224,8 @@ private static void writeState(File stateFileName, byte state) throws IOExceptio stateFile.write(state); stateFile.setLength(stateFile.getFilePointer()); stateFile.getFD().sync(); + } catch (SyncFailedException e) { + Log.w(TAG, "state file sync failed", e); } }