LordZoltan / PagerSlidingTabStrip.Net

Port of Java project of the same name by Andreas Stütz (https://github.com/astuetz/PagerSlidingTabStrip) for Xamarin.Android, written in C# .Net.
Apache License 2.0
17 stars 8 forks source link

Apps crash/restart when linking is enabled #2

Open LordZoltan opened 10 years ago

LordZoltan commented 10 years ago

I have observed a crash when linking is enabled and when Android starts a new process but restores an application back to a previous activity on which PagerSlidingTabStrip is hosted.

Looking through the log you will see a Java IllegalStateException being raised with the text something like - 'super.OnRestoreInstanceState was not called'

One way I found to repro this (might not work in all cases, however) is to start your app, and press Home when you have a tabbed activity showing. Then go to Android settings and terminate the process from the Apps sub-settings screen.

Now go back to your app (either from recent or by re-launching) and it should restart after loading.

The problem is caused by the linker stripping something (but I don't know what) out of the library when you enable linking. The easiest way around it is simply to exclude PagerSlidingTabStrip.dll from being linked.

A more thorough investigation could be conducted to find out exactly which methods need to be retained at all costs, however.

egfconnor commented 10 years ago

I've found this issue too. Easy way to reproduce is turn on the Android developer option of "Kill Activities" and then navigate to another activity from the one containing the TabStrip and then come back to it.

egfconnor commented 10 years ago

My exception I get is: java.lang.RuntimeException: Parcel android.os.Parcel@4245faa8: Unmarshalling unknown type code 7209057 at offset 376

Is this related?

LordZoltan commented 10 years ago

Yeah, that and the one I mention in the OP is the kind of thing that happens. Not linking the library should fix it. It's really hard to diagnose the exact problem in this case without instructing Xamarin not to strip any of the library, and then selectively start to remove those restrictions until you can repro it again.

Equally, there was another bug earlier in the codebase where you'd see this even if you weren't linking - basically caused by a bug in the state save & restore code - that should be fixed now... Hopefully! Certainly my first app, the JobServe app, no longer gets this problem.

egfconnor commented 10 years ago

@LordZoltan thanks for the quick reply. Updated my library to the latest codebase and it fixed it for me. Thanks for the help and library!

LordZoltan commented 10 years ago

I'm glad an update solved the problem :)

You're very welcome - I'm very pleased to have been able to bring this excellent library to the army of Xamarin .Net devs out there :)