-
Notifications
You must be signed in to change notification settings - Fork 837
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
Crash on ScanState.restore #1129
Comments
Two other exceptions demonstrate that the file "android-beacon-library-scan-state" is corrupted or incompatible with the update. -1- Of course there is not reason to try to allocate 4 Gb on the mobile device. -2- File version / integrity should be checked first before trying to deserialize the state. |
I agree with these proposed changes. I have also seen similar increases in crashes in an app I have in the Play Store -- it's unclear why this is happening now, but defensive programming seems like the only option to prevent it |
Hi! Would it be possible to release a quick bugfix update to address the IllegalStateException on restoring state and maybe fix the other issues later if they are more complex? |
See pull request here #1131 that shows my work so far. I have been busy with my day jobs, so this has been hold for the last couple of weeks. @paolorotolo if you can review the change and provide feedback that might speed things along. If you can do some end-to-end testing it would be even better -- that is the time consuming part. |
Thanks David, I didn't see you PR, I'll have a look! |
At the same stack trace. |
Thanks David. The defensive code, seems good for me. Other information: |
@03July why do you believe that this issue is a “problem linking to the upgrade of the dependencies which make the file incompatible”? Is that just conjecture, or do you have evidence that some upgrade is the cause? Upgrade of what? I am not sure how you detect if there was a previous crash in order to delete the file, but assuming you can do this effectively, the fact that you still see a 12 percent crash rate in daily users could mean that:
Any thoughts on the above appreciated. I want to be careful we understand the problem so any fix does not make things worse. |
Regarding using I am not sure of the implementation but the term “estimate” says to me that the API contract does not guarantee to tell you the total file size — for large files, perhaps it just tells you some max buffer size that could be read in a single shot. Even if the current implementation does return the max file size, it seems like the API docs suggest this could behave differently in a future implementation. |
@davidgyoung This beacon library is integrated in my app for many years now. And the 2.19.4 version is deployed since oct 2022 without any crashes (only ANR / deadlock from MonitoringRegions). The total crashes rate was only 0.48% before the upgrade. Thanks to the low crash rate of the previous version, I decided to use Firebase.crashlytics.didCrashOnPreviousExecution() as a workaround. Of course it can be any type of crashes but it a simple way to avoid the app to be blocked by this problem and continue to run normaly. |
@davidgyoung Regarding using FileInputStream.available() you're right it's a very slight optimisation so it is not worth the risk as the documentation is not clear enough for the estimate size (even if we don't need the exact file size but the buffer size won't do). Also the implementation may change in the future is for sure a stopper. |
Thanks for the answers, @03July. This is being published as 2.19.6-beta3. It should be available on Maven Central in an hour or so |
@davidgyoung Thanks, but 2.19.6-beta3 is still not available on Maven. |
Please check now. I was able to build and release an app with the new version from maven central. |
@davidgyoung Thanks. I successfully deployed 2.19.6-beta3. (Rollout at 1%) and I can still see a few OutOfMemoryError. |
I just published an update of my app with the same version 2.19.6-beta3 and there is no more crash (not even one) of type:
With the previous version of my app (same Beacon lib version). I had 7.23% crash rate. I don't see what really changed in my update (exempt the "Gradle JDK") which I switched back to "Android Studio java home" JetBrains Runtime version 11.0.15 C:\Program Files\Android\Android Studio\jbr. |
I have many crashes on :
Fatal Exception: java.lang.IllegalStateException
unread block data
org.altbeacon.beacon.service.ScanState.restore (ScanState.java:145)
This happen after the application update, it seems that the file "android-beacon-library-scan-state" is corrupted or incompatible with the update.
The exception should be caught and should be handled as if the serialized ScanState does not exist rather letting the app crash.
Beacon Library version: 2.19.5
This problem occurs on many manufacturer devices: Samsung, OPPO, Xiaomi, Huawei, Sony....
OS versions: 8,9,10,11,12 & 13
The full stack is
java.io.ObjectInputStream$BlockDataInputStream.setBlockDataMode (ObjectInputStream.java:2602)
java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1472)
java.io.ObjectInputStream.defaultReadFields (ObjectInputStream.java:2142)
java.io.ObjectInputStream.readSerialData (ObjectInputStream.java:2066)
java.io.ObjectInputStream.readOrdinaryObject (ObjectInputStream.java:1927)
java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1440)
java.io.ObjectInputStream.readObject (ObjectInputStream.java:428)
org.altbeacon.beacon.service.ScanState.restore (ScanState.java:145)
org.altbeacon.beacon.service.ScanJobScheduler.applySettingsToScheduledJob (ScanJobScheduler.java:102)
org.altbeacon.beacon.BeaconManager.applyChangesToServices (BeaconManager.java:1368)
org.altbeacon.beacon.BeaconManager.startMonitoringBeaconsInRegion (BeaconManager.java:1209)
org.altbeacon.beacon.startup.RegionBootstrap$InternalBeaconConsumer.onBeaconServiceConnect (RegionBootstrap.java:218)
org.altbeacon.beacon.BeaconManager.bindInternal (BeaconManager.java:462)
org.altbeacon.beacon.BeaconManager.bind (BeaconManager.java:427)
org.altbeacon.beacon.startup.RegionBootstrap. (RegionBootstrap.java:140)
com.k.basemanager.BaseManager$1.onSuccess (BaseManager.java:421)
com.k.basemanager.BaseManager$1.onSuccess (BaseManager.java:2)
com.google.common.util.concurrent.Futures$CallbackListener.run (Futures.java:1076)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
java.lang.Thread.run (Thread.java:1012)
The text was updated successfully, but these errors were encountered: