Closed dennischen closed 5 months ago
some more log today
----
## Start app after a long background idle
----
2024-05-19 09:03:26.756 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'App State Changed from', 'background', 'to', 'active'
### The backgournd ia running in 'active' !! doesn't it should only run in background?
2024-05-19 09:03:27.067 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Start backupDatabaseTask call at time:', 'Sun May 19 2024 09:03:27 GMT+0800'
2024-05-19 09:03:27.119 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Opened realm', '/data/data/com.colaorange.dailymoneyone/files/daily-money-one.realm', 'active'
2024-05-19 09:03:27.435 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Start to backup database automatically, auto upload config to true'
2024-05-19 09:03:27.436 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'Storage Uri', 'content://com.android.externalstorage.documents/tree/primary%3ADMO'
2024-05-19 09:03:27.436 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'Use Backup Dir', 'content://com.android.externalstorage.documents/tree/primary%3ADMO'
2024-05-19 09:03:27.449 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'New temp src to backup, size 723520', 'file:///data/user/0/com.colaorange.dailymoneyone/files/temp-backup.realm'
2024-05-19 09:03:27.535 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'New dest backup', 'content://com.android.externalstorage.documents/tree/primary%3ADMO/document/primary%3ADMO%2Fauto-dmo-20240519-0903.db'
2024-05-19 09:03:27.636 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'Copied temp backup from file:///data/user/0/com.colaorange.dailymoneyone/files/temp-backup.realm to content://com.android.externalstorage.documents/tree/primary%3ADMO/document/primary%3ADMO%2Fauto-dmo-20240519-0903.db'
2024-05-19 09:03:27.637 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Backed up to content://com.android.externalstorage.documents/tree/primary%3ADMO/document/primary%3ADMO%2Fauto-dmo-20240519-0903.db'
2024-05-19 09:03:33.125 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Uploaded auto-dmo-20240519-0903.db, size: 723520'
2024-05-19 09:03:33.176 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'Start to prune older auto backup retentionCount: 30, retentionDays: 30'
2024-05-19 09:03:33.244 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'End backupDatabaseTask call at time:', 'Sun May 19 2024 09:03:33 GMT+0800'
### although we close another realm instance, but it has same path as foreground realm. I think relam cache them by path
### so, the foreground realm will be closed too.
2024-05-19 09:03:33.247 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Closed Realm', '/data/data/com.colaorange.dailymoneyone/files/daily-money-one.realm'
------
## push app to background and start again.
------
2024-05-19 09:05:27.087 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'background', 'App State Changed from', 'active', 'to', 'background'
### this message is form dataService, which detected state changed to active, it will check dataService isClosed
2024-05-19 09:06:02.400 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'App State Changed from', 'background', 'to', 'active'
2024-05-19 09:06:02.403 10563-10640 ReactNativeJS com.colaorange.dailymoneyone W '[DM]>', 'active', 'dataService isClosed for unknow reason when app re-activating, reset it'
2024-05-19 09:06:02.605 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Opened realm', '/data/data/com.colaorange.dailymoneyone/files/daily-money-one.realm', 'active'
### this message is from unscuscribe a previous foreground dataService
2024-05-19 09:06:02.608 10563-10640 ReactNativeJS com.colaorange.dailymoneyone I '[DM]>', 'active', 'Realm is already closed'
2024-05-19 09:06:03.028 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'Registered Task', { taskType: 'backgroundFetch',
taskName: 'backupDatabaseTask',
options:
{ minimumInterval: 3600,
stopOnTerminate: false,
startOnBoot: true } }
2024-05-19 09:06:03.029 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'backupDatabaseTask.syncBackgroundFetch'
2024-05-19 09:06:03.762 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'report cost in v2 (quick)', 255
2024-05-19 09:06:04.153 10563-10640 ReactNativeJS com.colaorange.dailymoneyone D '[DM]>', 'active', 'report cost in v2 (quick)', 16
According to diagnosis #30, I found that realm instances are shared by path name (though there may be other conditions). Therefore, we need to count the number of create-close operations by path name to perform the actual close.
fixed the issue by added realm instance shared counter mapping by pathname
logcat.txt