Akavache: saved value not available after iOS app restart - ios

I am using Akavache standard approach on iOS (actually, it's .NET Standard project for Android/iOS), but the issue appears with iOS only.
I save some value during the app lifecycle:
await BlobCache.Secure.InsertObject("user", user);
And on the app new session this:
var user = await BlobCache.Secure.GetObject<UserModel>("user");
But the object is not available (with KeyNotFoundException exception).
Recently I also was trying to call BlobCache.Secure.Flush().Wait() right after the object saving, but there is still no effect.
The issue happens with iOS only. Android is fine.
The issue happens with both Secure and UserAccount objects.
The data is not available even after "gentle" BlobCache.Shutdown().Wait() on the application closing. So, have no idea even where to search the solution now.
Any thoughts why might cause this issue and how I can solve it?

There's another issue people have had is that the SqlLite cache is getting linked out. If you check the type on LocalMachine and it's of type MemoryCache that won't be resilient.
Just add the linker static class somewhere in your project (even if it's a PCL or Standard lib).
That worked for me.

Did you set the ApplicationName property on BlobCache? On iOS this seems more of a necessity than on Android it seems.

Related

React-Native ios App crashes without report

I'm building an iOS app using React Native and trying to get it testable on phones.
If I plug my phone into the computer and "build" directly to the phone, the app is built correctly and opens/operates correctly, no problem.
But if I try to archive it and send it to phones using iTunes Connect's TestFlight or Fabric with Crashlytics, the app crashes immediately upon opening. It briefly shows the launch screen, but no more.
Moreover, there are no crash reports -- in TestFlight, in Crashlytics, or in XCode, once I plug the phone back in. So I'm operating in the dark here, without any information on what's breaking. Haven't been able to find a similar issue online, so I figured I'd just ask. Any ideas what could be going wrong?
Please let me know if there's any code or other data you might need to see. Some of it's confidential, but I'll try to post an approximate version.
As Chris Geirman suggested, the problem was a JavaScript error. I'm not sure people with similar problems will find this thread, but in case they do, here is the weird error that was occurring.
I had created a simple ORM system, with a BaseModel and a bunch of models that inherited from it. The BaseModel constructor looked like this:
constructor(props = {}, relations = {}) {
Object.keys(props).forEach((k) => {
// Save props to object
this[k] = props[k];
});
this.relations = relations;
this.className = this.constructor.name;
}
That last line was the problem. On my local simulator and if I build the app to my phone by plugging it in, this works fine. As in, if a Message model inherits from BaseModel, calling var msg = new Message(data, relations); msg.className returns Message.
But something about bundling/archiving/sending the app through TestFlight or Fabric.io minifies and uglifies the JavaScript, such that the class names are changed. So instead, if I do this -- var msg = new Message(data, relations); msg.className -- I'll get back a random variable name, something like 't'.
This was a problem in my app, because my home page contained a switch statement that worked off of the className:
iconContent() {
return {
Message: {
icon: <Image style={styles.feedItemIconImage} source={ require('../assets/img/icon_message.png') } />,
color: c.grass
}, ...
}[this.props.className] // from the model item
}
But 'Message' wasn't, as expected, the value of this.props.className -- 't' was. And so, if I were to try to tunnel into, say, the color value, I'd hit an error, because I was trying to access the color property of null.
Why that didn't report, I don't know (I followed Chris's suggestions and installed Sentry, but it still seemed not to report that error).
But that's what was going on. Minification/uglification occurred only when I installed the app on a phone via TestFlight/Fabric, and that's why the app only crashed in those conditions.
Hope this saves anyone running into a similar bug from tearing out their hair.
I'd like to share my own experience of production stage crash, whereas everything worked fine in development stage.
I had the similar problem which caused by the Reactotron logger. Since I'm not bundling it in production stage, a single line of console.tron.log crashed my app with full stealth. (Its kinda my fault, since I didn't give a damn about my linter with 'no-console' setting)
Here's the code snippet I introduce in my root level file, root.js.
if (__DEV__) {
...
console.tron = Reactotron;
...
}
Hope somebody finds this before wasting time figuring out what's wrong.
Not sure if you still have this problem - but if you do, I'd recommend checking out Bugsnag for react native error reporting - which reports crashes in both the JavaScript layer as well as the native layers (java/cocoa).
One of the harder problems to solve in react native crash reporting (as Sasha mentioned) is restoring the original stack traces when using minification and/or obfuscation - this is handled in Bugsnag by providing full support for JS source maps, as well as iOS symbolication and Android Proguard support at the native layers.
Let me know if this helps - I'm a founder # Bugsnag

Application.Current.properties is broken in latest xamarin forms release?

Since I've updated my xamarin installation to xamarin 4, saving local properties is not working across sessions on iOS.
so if I have
Application.Current.Properties.Add("key", value);
Application.Current.SavePropertiesAsync();
It's not saving anything when the app is closed & restarted.
Any pointers?
This was fixed by not saving the complex objects as it is, but serializing them to string using JsonConvert & then storing the string instead.
This works all the time.
When you want to retrieve the object back again, just deserialize the string to the object type.
This seems to be a bug in Xamarin Forms 2, revert back to the latest v1 to get it working again.
See http://forums.xamarin.com/discussion/56461/persisting-data-locally-device-cache#latest
You should NOT use Xamarin Forms 2 yet, it is not production ready yet and should be considered alpha, don't believe Xamarins marketing.

iOS 8 Safari indexedDB.open returns null

We are developing web app, that uses framework that uses indexedDB. All was going fine, but then we tested it on iPad and suddenly it didn't load the page at all. Thought it would be some minor issue, but after some tests we found out, that the app is crashing on:
TypeError: null is not an Object validating 'request'
It crashes on the line :
var request = indexedDB.open("FMVare",415);
This stores null in the request variable so then after that there is:
request.onerror(...)
Which will get us the error message, written above.
I spent one day looking for a fix, but only found that iOS implemetation of indexedDb is "buggy". But I cant even open a database, so there probably is problem somewhere else. My colleague also told me, that it was working fine like 1 month before, but the file with this implementation (according to git) didn't change... ever.
I tried using pollyfill to change it to the WebSQL, again it worked everywhere except iPad browsers (Safari, Chrome). This time it was throwing different error, which I only could google as far as some SQL syntax error, which obviously couldn't be the case, if it is working everywhere else.
I have tried some suggestions, which said to replace in that pollyfill indexedDB with _indexedDB etc. but again, it worked everywhere but iPad.
When I log the variable request, it returns null. If I log indexedDB or window.indexedDB, it returns IDBFactory object, so it's there, but the .open method is failing, without calling .onerror or .onsucess method.
Since I really found many people complaining about indexedDB bad implementation on iOS, it means they were able to use it. So what could be the problem in my iPad? I mean I can try update to iOS 9, but that's not exactly what are we trying to achieve.
I tried deleting cache, changing version number(greater and smaller), creating different database (different name), pollyfill... but still can't get it working, everytime i call indexedDB.open(databasename), it returns null and crashes.
Any ideas?
EDIT:
The error I'm getting with shim is
Error in sysdb transaction - when creating dbVersions.
Then I get the SQLError object with
"code: 5"
and
"message: could not prepare statement (1 not authorized)"
The error happens in createSysDB(success, failure) function of the shim.
UPDATE:
I tried an app on iPad called WebView Rendering so i could try if WKWebView would be capable of running my app. And it was! So the problem really was the UIWebView support of IndexedDB.
Seems very strange to me though, that you can't use IndexedDB on iOS Safari even after update on latest iOS version.

Web service call missing field value xamarin IOS

I'm having a web reference which is being used by both a Xamarin IOS application, Xamaring Android application, and a Windows Store application.
And this all worked very well, until I updated Xamarin.
Now, there is a field that But it works fine for the Android and Windows applications.
I have tried to update the web reference multiple times, with no luck. I have also tried to debug the web service locally, to see if it returns the same , which it does.
When I receive it in my Windows Store app., it looks like this:
And in my IOS app., it looks like this:
It is always the StructureId that is never set, for some reason. And it was not like that before I updated Xamarin.
Anyone who knows what I am doing wrong, or have stumbled onto the same kind of problem ?
That looks like the linker removed unused members. Defaults have not changed (it's not related to your update) but you should check that your application is being built with Link SDK (and not Link all).
If you want a smaller executable and set Link all to achieve this then you'll need to add [Preserve] attributes on the structure you're serializing (e.g. used in web services).
I was able to make it work. I am not sure if it cached anything, or what, but it helped to add some "noise" on the webservice call.
I just added DateTime.Now.Ticks to my webservice URL in Reference.cs, so it would always be a new URL call:
this.Url = "http://somewebsitename.com/ReportService/ReportService.asmx?v=" + DateTime.Now.Ticks;

FireFox 6: implementing nsIProtocolHandler

Has something changed in Firefox 6 so I can no longer add my nsIProtocolHandler (and nsIChannel) implementation from an add-on just by registering it under a contract like #mozilla.org/network/protocol;1?name=myscheme?
I've checked all the interfaces I use if any changed (judging by a new
UUID), but I don't get a call to my getFactoryProc I list in NSModule,
like I did before.
Do I need to add a category (like http-startup or something?) or is
something else wrong?
(the code that worked in firefox 3.6 is still here I haven't committed
the new code yet...)
Update: I've logged this as a bug.
Update: Okay, I figured this out. See https://bugzilla.mozilla.org/show_bug.cgi?id=656331. Basically you need to export the right kVersion value in your module or the library will be unloaded immediately after it is loaded (i.e. the behavior you are observing). This behavior is new as of Firefox 5.
If you haven't updated to Firefox 4 yet then you need to change the way that you register your XPCOM component. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0. The sections on JS components or binary components are relevant depending on whether your component is implemented in JS or C++.

Resources