Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotation bug at loading #52

Open
RoelD opened this issue Jun 12, 2015 · 5 comments · May be fixed by #60
Open

rotation bug at loading #52

RoelD opened this issue Jun 12, 2015 · 5 comments · May be fixed by #60
Labels

Comments

@RoelD
Copy link

RoelD commented Jun 12, 2015

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 AndreiLux added the bug label Jun 12, 2015
@AndreiLux
Copy link
Owner

Thanks, just reproduced.

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

@RoelD
Copy link
Author

RoelD commented Jun 12, 2015

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
Copy link
Owner

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

@RoelD
Copy link
Author

RoelD commented Jun 12, 2015

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
Copy link
Contributor

duki994 commented Aug 8, 2016

@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.

duki994 added a commit to duki994/Synapse that referenced this issue Aug 9, 2016
…ivity

Fixes AndreiLux#52

Logcat showed that error happened while invoking onConfigurationChanged method in mDrawerToggle, but didn't provide crash info.
Forcing portrait layout until all fragments have been loaded fixes rotation bug on loading app.

setRequestedOrientation will block invoking onConfigurationChanged for orientation events, but screenSize changes when orientation is changed will invoke it, thus avoiding this bug and properly notifying mDrawerToggle.
duki994 added a commit to duki994/Synapse that referenced this issue Aug 9, 2016
Commit:
464d92f fixed issue AndreiLux#52

That commit also made new bug (or rather exposed what was happening in AndreiLux#52).
On each rotation, Settings was unable to instantiate MyPreferenceFragment. Each time rotation changed while user was in settings menu, Synapse would crash due to InstantiationException

Fix this by moving MyPreferenceFragment out of Settings and making it outer standalone class.
@duki994 duki994 linked a pull request Aug 9, 2016 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants