AndreiLux / Synapse

Please read the introduction to create a working backend:
https://github.com/AndreiLux/Synapse/wiki
Other
38 stars 22 forks source link

rotation bug at loading #52

Open RoelD opened 8 years ago

RoelD commented 8 years ago

This bug is easy to reproduce. Open synapse, and rotate the device while the settings are loading (spinner is still going). The app will force close. Rotation works fine when the settings are loaded.

Very minor bug, and i only saw it by accident.

AndreiLux commented 8 years ago

Thanks, just reproduced.

Just a question, what phone/config are you using that you have such long load times?

RoelD commented 8 years ago

i9300 with archidroid experimental lollipop. http://forum.xda-developers.com/galaxy-s3/development/rom-archidroid-v2-4-6-power-hands-t2354859 in combination with ArchiKernel. http://forum.xda-developers.com/galaxy-s3/development/kernel-archikernel-v1-0-power-hands-t2785337. 2.0 kernel. not yet released though.

Loading all settings takes about 2.5 ~ 3 seconds.

AndreiLux commented 8 years ago

Ah OK, the S3 is an older device. 3s sounds fine for that CPU.

RoelD commented 8 years ago

yeah. I'm waiting for the nexus 5 2015 to upgrade, but for now it is a adequate device with adequate CPU.

The bug is not even that annoying now i know it. I rotated my device by accident and it crashed.

duki994 commented 7 years ago

@AndreiLux

I had this bug when my RAM was overloaded with apps. Logcat is obscure, but it seems that ART itself bugs. Rotation bug is caused by line 250 in MainActivity

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setPaddingDimensions();
        mDrawerToggle.onConfigurationChanged(newConfig); /* crashes here*/
    }

I think the problem is that when rotation happens, Fragments haven't been fully loaded, and ActionBarDrawerToggle is having some sort of bug with instant new configuration.

Maybe saving each fragment data by using Fragments setRetainInstanceState method and Activity's onSaveInstanceState and onRestoreInstanceState and reloading that data when onCreate is called after orientation change will fix the problem.

If user has some big JSON config file, then memory requirements for such Fragment data saving would be big and slow the application.

One of workarounds would be to lock orientation while all Fragments are loaded, and then unlock it via setRequestedOrientation method. I'll explore this solution when I have time.