Acknowledged

Data is missing after "Storage.setValue()" call in background

SDK 7.3.1 and 7.4.3, up-to-date real and simulated CIQ 5 device (writing to storage in background is allowed).

Forum does not allow me to insert code in any text form except for Base64. Please, use any decoder to get it:
aW1wb3J0IFRveWJveC5BcHBsaWNhdGlvbjsKaW1wb3J0IFRveWJveC5BcHBsaWNhdGlvbi5TdG9y
YWdlOwppbXBvcnQgVG95Ym94LkJhY2tncm91bmQ7CmltcG9ydCBUb3lib3guTGFuZzsKaW1wb3J0
IFRveWJveC5TeXN0ZW07CmltcG9ydCBUb3lib3guVGltZTsKaW1wb3J0IFRveWJveC5UaW1lLkdy
ZWdvcmlhbjsKaW1wb3J0IFRveWJveC5XYXRjaFVpOwoKKDpiYWNrZ3JvdW5kKQpjbGFzcyBTdG9y
YWdlVGVzdEFwcCBleHRlbmRzIEFwcEJhc2UgewogICAgY29uc3QgVkVSU0lPTiA9ICJ2ZXJzaW9u
IjsKICAgIGNvbnN0IEtFWSA9ICJrZXkiOwogICAgY29uc3QgVkFMVUUgPSAidmFsdWUiOwoKICAg
IGZ1bmN0aW9uIGluaXRpYWxpemUoKSB7CiAgICAgICAgQXBwQmFzZS5pbml0aWFsaXplKCk7Cgog
ICAgICAgIGluaXRTdG9yYWdlKCk7CiAgICB9CgogICAgZnVuY3Rpb24gb25BcHBVcGRhdGUoKSBh
cyBWb2lkIHsKICAgICAgICBCYWNrZ3JvdW5kLmRlbGV0ZVRlbXBvcmFsRXZlbnQoKTsKICAgICAg
ICBCYWNrZ3JvdW5kLnJlZ2lzdGVyRm9yVGVtcG9yYWxFdmVudChuZXcgRHVyYXRpb24oMTUgKiBH
cmVnb3JpYW4uU0VDT05EU19QRVJfTUlOVVRFKSk7CiAgICB9CgogICAgKDp0eXBlY2hlY2soZGlz
YWJsZUJhY2tncm91bmRDaGVjaykpCiAgICBmdW5jdGlvbiBnZXRJbml0aWFsVmlldygpIGFzIFtW
aWV3c10gb3IgW1ZpZXdzLCBJbnB1dERlbGVnYXRlc10gew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NJT04pIGFzIE51bWJlcj9dKSk7
CiAgICB9Cn0K
Screenshot is in the first comment.

Build and run app first in release mode, then in debug.

The problem does not relate to exclude annotations or differences in debug/release builds. I use these annotations here to simplify testing and have possibility to quickly switch back and forth between two versions of the same code.

Log from the first (release) run:
Background: initStorage 'version' expected=1, stored=1
initStorage 'version' expected=1, stored=1
getInitialView 'version' expected=1, stored=1
Everything is OK so far - we just need to set initial value of version before the second run, where the issue occurs.

Log from the second (debug) run:
Background: initStorage 'version' expected=[1 or 2], previous=1
Background: initStorage 'key' expected=value, stored=value
Background: initStorage 'version' expected=2, stored=2
initStorage 'version' expected=[1 or 2], previous=2
getInitialView 'key' expected=value, stored=null
getInitialView 'version' expected=2, stored=2
Note the difference between expected and actual value of key. The worst part is that version value is updated, but key is not, so it's not possible to correctly migrate data in storage after app update from main app thread either.

I really need updated storage before the first call of ServiceDelegate.onTemporalEvent()/AppBase.getInitialView()/AppBase.getGlanceView().