FORUMS
Remove All Ads from XDA

 View Poll Results: Did you tried and it worked?

YES! It worked without problems.
 
110 Vote(s)
64.33%
Yes, but not easy, required further editing.
 
12 Vote(s)
7.02%
NO, unfortunately that did not helped.
 
24 Vote(s)
14.04%
I don't understand what it is about....
 
25 Vote(s)
14.62%

[WORKAROUND] Bootloops due leaking handles with Xposed in Lollipop

1,830 posts
Thanks Meter: 1,291
 
By ondrejvaroscak, Senior Member on 22nd April 2015, 01:39 AM
Thread Closed Email Thread
Fix found and released:

http://forum.xda-developers.com/show...php?p=60454547

Downloads & instructions: http://forum.xda-developers.com/show....php?t=3034811

Discussion & Q&A:http://forum.xda-developers.com/xpos...lipop-t3030118

I asked moderator to close this thread as issue was fixed by releasing new version of Xposed framework. Please send your further questions and post to respective thread.





This thread is about workaround found for bootloops of Xposed in XPERIA family Lollipop. Because of development progress, I have decided to remove historical development, you can see it here:

LATEST VERSION will be always posted at the END of this post

PLEASE READ INSTRUCTIONS .... The attachment IS NOT flashable!!! For flashables see EDIT 5 and bellow...

I hope I can present some good news for users with locked bootloaders who are getting bootloops with Xposed and Lollipop.

This is still continuous WIP. Know what you do, this is a development thread.

For time being, most complete solution by my opinion was made by @mionica, see EDIT 6 and hist post http://forum.xda-developers.com/show...postcount=123? and for latest development at http://forum.xda-developers.com/show...&postcount=285

As you may already know, we have find out, that some undetected error is causing system to bootloop, if too many applications are installed.
Exact numbers are varying between different ROMs and devices, generally the maximum number of apps is about 320-330.
Debloating (uninstalling unnecessary apps) helps, but remains limiting and for many frustrating. After a research, we have found out,
that there is probably a bug, that is causing many files being left open when booting Lollipop with Xposed.

Users on unlocked bootloader may modify certain kernel parameters to raise number of open files. This can not be done on Locked Bootloader.
After some research and hours of experiments, I found a way, how to change the filelimit for Zygote and subsequent processes. Therefore every child of zygote (hence every app etc.) will inherit raised open files limit from 1024 to 4096.

This change should work on all 5.0 compatible system, not only XPERIAs, however I only tested it on Z3 D6603 fw 690. But the modification
is done on Linux system level, therefore it should teoretically work just everywhere... It should work also on Locked bootloaders as well.

The principle is easy, however implementation was a tricky, because of lack of native linux utils support on Android and fact that we can not
easily modify booting behaviour. But gladly enough we have XZDualRecovery (gret thanks @[NUT])....

XZDualRecovery enables to call init scripts on startup. I have created a startup script that waits for zygote process to come up, and calls
external program that changes open file limits for that process. This external program is compiled by me from source provided by http://lzone.de/cheat-sheet/ulimit

Prerequisities: Functional XZDualRecovery or other form of init.d support.

Installation:

Extract downloaded ZIP file, it contains:
flimit-binary executable for changing open file limits
01_flimit - shell script called by init
flimit.c - source code of binary executable

Enable init.d support in XZDualRecovery by editing XZDR.prop and change dr.initd.active=true
Dont forget to have enabled byeselinux (dr.keep.byeselinux=true)
copy flimit and 01_flimit to /data/local/tmp (or push adb)
remount /system rw (mount -o remount,rw /system)
create directory /data/flimit
copy flimit to /data/flimit and make executable (chmod 777)
create directory /system/etc/init.d with and chmod 777 /system/etc/init.d
copy 01_flimit to /system/etc/init.d and chmod 777 /system/etc/init.d/01_flimit

test run installation:
Code:
su
/data/flimit/flimit $(pgrep zygote)
output should be:
Code:
root@D6603:/data # /data/flimit/flimit $(pgrep zygote)                       
Previous limits: soft=1024; hard=4096
New limits: soft=4096; hard=4096
If not, check permissions etc.

Check script by running:
Code:
su
sh /system/etc/init.d/01_flimit
it should now give output (if you succesfully ran /data/flimit/flimit....):
Code:
root@D6603:/data # /data/flimit/flimit $(pgrep zygote)                       
Previous limits: soft=4096; hard=4096
New limits: soft=4096; hard=4096
reboot

Thats all. Now you can install and update lot more applications. Now I have about 455 packages reported by pm list packages and no bootloop.
But as soon as I disable the init.d support, it bootloops. So re-enable by edititng XZDR.prop and it again boots.

EDIT:Please let me know, if you had to modify the script or instructions to work on your device, so I can perhaps make better or more universal version. Thank you guys.

EDIT 2:While this workaround makes it possible to run Xposed on untouched vanilla Stock ROM, you may still consider debloating it, as debloating will make run your device more smoothly and saves battery. Guys who made debloating scripts made significant efforts in identifying which apps can be safely removed without harming any significant functionality.

EDIT 3:The ZIP is NOT flashable, follow instructions ^^^^ --- buddy @McBane87 is developing flashable version.

EDIT 4:Buddy @nurps found a bug causing Opera browser to quit upon starting. @mionica proposed lowering softlimits for open files to 2048 from 4096 in first version of script. Version 1.1 is released.

EDIT 5:Buddy @McBane87 created customized flashable version of this workaround, so you can flash it from recovery if you struggle with bootloops, dont like to wait fro 300apps to optimize after Dalvik wipe and mess with adb/terminal..
http://forum.xda-developers.com/show...php?p=60276913

EDIT 6:Buddy @mionica published another flashable zip. It is complete installer for the workaround, so far most sofisticated workaround from system point of view. The uninstaller completely removes Xposed if you are too tired of it and forgot to make backup Files are bellow, for instructions etc. check it out on http://forum.xda-developers.com/show...&postcount=123 and for latest development at http://forum.xda-developers.com/show...&postcount=285

Changelog:

v1: Initial release
v1.1: Changed limits to 2048 from 4096 as high limits caused Opera Webbrowsers to crash
v2.0 Reference script - for production please flash @mionica version of flashable, my script is published for educational purposes. added mionicas mod to detect only changed limits and subsequently remove only those that are child of zygote

***************************************
I would like to thank mainly to @[NUT] and to guys who made significant effort with debloating, made other discoveries or were an inspiration
for me, including but not limited to @serajr @moly82 @AndroPlus (for his work on file limits in kernel) @redincali and of course to @rovo89
for his Xposed framework. My apologies if I forgot someone, PM me, its 2 o'clock in morning

or in this post http://forum.xda-developers.com/show...&postcount=354

While I have developed initial version (see history), other guys (mainly @mionica and @McBane87) greatly enhanced and redeveloped whole thing.

Current development version and downloadable files you can always find in @mionica post http://forum.xda-developers.com/show...&postcount=123

@mionica managed to analyze boot process on both ROMs with and without Xposed and came to conclusion that leaks are caused by Xposed process leaking open file handles, see here http://forum.xda-developers.com/show...&postcount=417

There is a current version of the workaround fix (see above), that seems to be the last possible, before Xposed will be released with patch addressing that issue. Good news is that thanks to @mionica precise analysis, @rovo89 - developer of Xposed is already aware of the problem nad it´s cause.


[B] Recommended installation steps:

Quote:

by @mionica
Anybody who is still having any kind of issues, for whatever reason, please do the following:

  • get into TWRP;
  • install, in this order, without rebooting:
    • xposed-uninstall-v1.1.zip
      • If you don't have an sd card, you'll need to reboot once after the uninstall .zip, boot the system normally, then get back in the recovery and install the other 3. This only applies to people who don't use an SD card
    • xzdr-busybox-enable-v1.0.zip
    • xposed-sdk21-arm-date.zip
    • xposed-leakplug-v1.2.zip
  • copy the logs to the PC, over USB:
    • uninstall_xposed.log
    • install_busybox.log
    • install_leakplug.log
    each of the 3 zip's will tell you where it saved the log (it's usually the external sdcard)
  • reboot to system

Thanks in advance for not asking any questions about whether you have to do any of these steps; yes, you have to.

If you follow other instructions than provided by @mionica please get then support from someone else than him.

The basic idea behind is that Xposed bootloops because of it exhausted resources available due to probably internal bug. The workaround basically provides higher limits for open files during boot and restores previous limits after device has booted. The latest flashable installer is very advanced and automates the installation, including necessary checks for proper XZDR configuration, busybox etc.

When you experience bootloops after installing Xposed, or you had Xposed working and it started to bootloop after you have installed new app or upgraded a system app, simply reboot to recovery and flash the zip. No need to wipe anything.

When installing new, I recommend flashing this zip first, then install Xposed usual way (flash, wipe, reboot, install Xposed apk, install modules).

Be aware that while the workaround works for about 80% of cases, there are people who have lots of applications or heavily modified system, experiencing random reboots. Cause is under investiogation, but most probably is in Xposed itself.
The Following 163 Users Say Thank You to ondrejvaroscak For This Useful Post: [ View ] Gift ondrejvaroscak Ad-Free
 
 
22nd April 2015, 02:33 AM |#2  
ogunja's Avatar
Senior Member
Flag São Paulo
Thanks Meter: 673
 
Donate to Me
More
Excellent work friend @ondrejvaroscak. Congrats! Awesome
The Following 3 Users Say Thank You to ogunja For This Useful Post: [ View ] Gift ogunja Ad-Free
22nd April 2015, 04:24 AM |#3  
Advali's Avatar
Senior Member
Flag Makati City
Thanks Meter: 18
 
More
Was waiting a long time for this! Thanks man! working perfectly.
22nd April 2015, 05:13 AM |#4  
Member
Thanks Meter: 3
 
More
Working perfectly on D6603, thanks
22nd April 2015, 05:33 AM |#5  
NetSkill's Avatar
Senior Member
Flag Slovakia
Thanks Meter: 223
 
More
I am gonig to try this asap! Awesome job!
One more thing, if i understand right, now we can install as many apps as we want or the limit is just higher but still there?

Can we now use regular reboot button from power menu withouth getting bootloop?

--Guys lets go ahead and rape the thanks button
The Following 2 Users Say Thank You to NetSkill For This Useful Post: [ View ] Gift NetSkill Ad-Free
22nd April 2015, 05:43 AM |#6  
norti's Avatar
Senior Member
Flag Budapest
Thanks Meter: 487
 
More
Thank you @ondrejvaroscak for this solution!

@rovo89 any chance this could be integrated in the xposed installer?
22nd April 2015, 05:47 AM |#7  
xtremepredador's Avatar
Senior Member
Flag Brasil
Thanks Meter: 316
 
More
Thanks Bro , Very Nice !!

Perfect Work !!
22nd April 2015, 06:36 AM |#8  
Senior Member
Flag Seongju
Thanks Meter: 38
 
More
Thumbs up Z1, C6903
Thank you for this great solution, works on Z1.
22nd April 2015, 06:55 AM |#9  
ondrejvaroscak's Avatar
OP Senior Member
Flag Aachen
Thanks Meter: 1,291
 
More
Quote:
Originally Posted by NetSkill

I am gonig to try this asap! Awesome job!
One more thing, if i understand right, now we can install as many apps as we want or the limit is just higher but still there?

Can we now use regular reboot button from power menu withouth getting bootloop?

--Guys lets go ahead and rape the thanks button

Unless I will be blessed with some debugging skills, I have no clue... I think limit is just much higher. Once you reach limit you can simply edit script and change two numbers...

Yes, now regular reboot works.

Sent from my D6603 using XDA Free mobile app
The Following User Says Thank You to ondrejvaroscak For This Useful Post: [ View ] Gift ondrejvaroscak Ad-Free
22nd April 2015, 07:16 AM |#10  
ondrejvaroscak's Avatar
OP Senior Member
Flag Aachen
Thanks Meter: 1,291
 
More
Quote:
Originally Posted by norti

Thank you @ondrejvaroscak for this solution!

@rovo89 any chance this could be integrated in the xposed installer?

I think it will take time, because first @rovo89 would probably want to investigate, how much is it a bug, a constellation of coincidences and so on. I am not sure, if the same bootloops appear only on XPERIAs or it is a phenomenon on other brands as well... And given the fact, that big number of Samsungs can not run Xposed at all, maybe he will try to solve that Samsung puzzle as priority. But that is only guess..
22nd April 2015, 08:42 AM |#11  
Senior Member
Thanks Meter: 50
 
More
Working on fully setup 5.02 on Z2 thanks.
Thread Closed Subscribe to Thread

Tags
bootloop, solution, workaround, xperia, xposed
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes