[Sony Cross-Device General] ondrejvaroscak:
Fix found and released:

http://xdaforums.com/showthread.php?p=60454547

Downloads & instructions: http://xdaforums.com/showthread.php?t=3034811

Discussion & Q&A:http://xdaforums.com/xposed/official-xposed-lollipop-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 [MENTION=1103233]mionica[/MENTION], see EDIT 6 and hist post http://xdaforums.com/showpost.php?p=60298690&postcount=123? and for latest development at http://xdaforums.com/showpost.php?p=60333600&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 [MENTION=4904057][NUT][/MENTION])....

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:

su
/data/flimit/flimit $(pgrep zygote)

output should be:

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:

su
sh /system/etc/init.d/01_flimit

it should now give output (if you succesfully ran /data/flimit/flimit....):

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 [MENTION=4712883]McBane87[/MENTION] is developing flashable version.

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

EDIT 5:Buddy [MENTION=4712883]McBane87[/MENTION] 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://xdaforums.com/showthread.php?p=60276913

EDIT 6:Buddy [MENTION=1103233]mionica[/MENTION] 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://xdaforums.com/showpost.php?p=60298690&postcount=123 and for latest development at http://xdaforums.com/showpost.php?p=60333600&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 [MENTION=1103233]mionica[/MENTION] 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 [MENTION=4904057][NUT][/MENTION] and to guys who made significant effort with debloating, made other discoveries or were an inspiration

for me, including but not limited to [MENTION=3989065]serajr[/MENTION] [MENTION=4695495]moly82[/MENTION] [MENTION=5169444]AndroPlus[/MENTION] (for his work on file limits in kernel) [MENTION=1897172]redincali[/MENTION] and of course to [MENTION=4419114]rovo89[/MENTION]

for his Xposed framework. My apologies if I forgot someone, PM me, its 2 o'clock in morning :)

or in this post http://xdaforums.com/showpost.php?p=60349914&postcount=354

While I have developed initial version (see history), other guys (mainly [MENTION=1103233]mionica[/MENTION] and [MENTION=4712883]McBane87[/MENTION]) greatly enhanced and redeveloped whole thing.

Current development version and downloadable files you can always find in [MENTION=1103233]mionica[/MENTION] post http://xdaforums.com/showpost.php?p=60298690&postcount=123

[MENTION=1103233]mionica[/MENTION] 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://xdaforums.com/showpost.php?p=60373854&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 [MENTION=1103233]mionica[/MENTION] precise analysis, [MENTION=4419114]rovo89[/MENTION] - developer of Xposed is already aware of the problem nad it´s cause.

Recommended installation steps:

If you follow other instructions than provided by [MENTION=1103233]mionica[/MENTION] 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.