objectbox / objectbox/objectbox-java
io.objectbox.exception.FileCorruptException: Could not get from cursor (corrupted) (error code -30796)
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
In my Pre-launch report details I see continuously crashes on Android 8.1 phones. I cannot reproduce it on a Emulator with SDK 27. Stacktrace error (see for log details below): io.objectbox.exception.FileCorruptException: Could not get from cursor (corrupted) (error code -30796)
Is this a issue with pre-launch testing or might this occur on real devices as well? After searching I found multiple issues with Android 8.1. Any clue?
I'm using a read-only box from a fragment (write box is in a remote service).
- ObjectBox version 2.8.0 (but also on 2.7.1)
- Reproducibility: always on Android 8.1 devices for pre-launch report
- Device: e.g. Motorola moto e5 play and Nokia Nokia 1
- OS: Android 8.1
Code
Initialization done in MainActivity class after being connected to Service (remote process). The method initMainActivity is called.
protected void initMainActivity() {
if (!mInitMainActivity) {
JepsterManager jepsterManager = (JepsterManager) getApplication();
jepsterManager.initReadOnlyBox();
//Check if version is updated and update information has to be shown
JepsterVersionUtilities.checkVersion(this, mService, mPreferences);
//Check version to verify if preference migration is needed
PrefsMigrationUtilities.checkVersion(this, mPreferences);
setNavigationHeader();
mInitMainActivity = true;
//ObjectBox need to be available, JepsterService has to be started first to be able to update schema of Box.
if (mOnPostResume){
selectDrawerItem(mMenuItemId);
}
}
}
public class ObjectBox {
private static BoxStore boxStore;
private static int messageId = 0;
public static void init(Context context) {
if (boxStore == null) {
boxStore = MyObjectBox.builder()
.androidContext(context.getApplicationContext())
.androidReLinker(ReLinker.log(new ReLinker.Logger() {
@Override
public void log(String message) {
Log.d(Constants.TAG, message);
}
}))
.build();
if (BuildConfig.DEBUG) {
boolean started = new AndroidObjectBrowser(boxStore).start(context);
}
}
}
public static void initReadOnly(Context context) {
if (boxStore == null) {
boxStore = MyObjectBox.builder()
.androidContext(context.getApplicationContext())
.androidReLinker(ReLinker.log(new ReLinker.Logger() {
@Override
public void log(String message) {
Log.d(Constants.TAG, message);
}
}))
.readOnly()
.build();
if (BuildConfig.DEBUG) {
boolean started = new AndroidObjectBrowser(boxStore).start(context);
}
}
}
public static BoxStore get() {
return boxStore;
}
public static int getMessageId(){
messageId ++;
return messageId;
}
}
public int getDataFieldValue(int bike, int page, int dataField){
Box<BikeDataFieldEntity> bikeDataFieldBox = getBikeDataFieldBox();
//Search data field ID
QueryBuilder<BikeDataFieldEntity> builder = bikeDataFieldBox.query();
builder.equal(BikeDataFieldEntity_.bike, bike)
.equal(BikeDataFieldEntity_.page, page)
.equal(BikeDataFieldEntity_.dataField, dataField);
Query<BikeDataFieldEntity> query = builder.build();
BikeDataFieldEntity bikeDataField = query.findFirst(); (**Line 321**)
return bikeDataField.getDataFieldValue();
}
public Box<BikeDataFieldEntity> getBikeDataFieldBox(){
if (mBikeDataFieldBox == null){
mBikeDataFieldBox = ObjectBox.get().boxFor(BikeDataFieldEntity.class);
}
return mBikeDataFieldBox;
}
Logs, stack traces
io.objectbox.exception.FileCorruptException: Could not get from cursor (corrupted) (error code -30796)
at io.objectbox.query.Query.nativeFindFirst(Native Method)
at io.objectbox.query.Query.lambda$findFirst$0$Query(Query.java:153)
at io.objectbox.query.-$$Lambda$Query$U3Pw2NlOHcqDE3imeFDwfgwkeJw.call(Unknown Source:2)
at io.objectbox.BoxStore.callInReadTx(BoxStore.java:813)
at io.objectbox.BoxStore.callInReadTxWithRetry(BoxStore.java:759)
at io.objectbox.query.Query.callInReadTx(Query.java:275)
at io.objectbox.query.Query.findFirst(Query.java:151)
at com.twom.bico.pages.FragmentPageDataFields.getDataFieldValue(FragmentPageDataFields.java:321)
at com.twom.bico.pages.FragmentPageDataFields.initViews(FragmentPageDataFields.java:111)
at com.twom.bico.pages.FragmentPage9DataFields.onCreateView(FragmentPage9DataFields.java:31)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2169)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1992)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1818)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
at androidx.fragment.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:270)
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 FragmentPageDataFields.java 第 321 行的堆栈跟踪开始,将 ObjectBox.initReadOnly 中的只读初始化与远程服务设置进行比较。使用提供的设备详细信息和日志,在 Android 8.1 设备或预发布环境中重现该查询。完成标准是确定该损坏是否仅限于预发布测试,还是也可能发生在真实设备上,并记录原因或下一步诊断步骤。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, java
- 领域
- database, mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100