Crash Defender

* Fixed missing cache file from android builds
* Added crash defender workaround for devices with borked OGL implementations
This commit is contained in:
LoafyLemon 2022-07-07 22:05:22 +01:00
parent 330173d510
commit 22588ba646
3 changed files with 33 additions and 6 deletions

View File

@ -288,6 +288,17 @@ screen preferences_accessibility():
style gui.theme("pref_button")
action Confirm(gui.CONFIRM_DELETE_SAVES, Function(delete_saves))
if renpy.android:
label _("Android Crash Defender")
hbox:
style_prefix gui.theme("radio")
textbutton "Aggressive" action [settings.Set("crashdefendersetting", 3), Function(crashdefender.set_mode, 3)]
textbutton "Balanced" action [settings.Set("crashdefendersetting", 2), Function(crashdefender.set_mode, 2)]
textbutton "Relaxed" action [settings.Set("crashdefendersetting", 1), Function(crashdefender.set_mode, 1)]
textbutton "Off" action [settings.Set("crashdefendersetting", 0), Function(crashdefender.set_mode, 0)]
define gui.CONFIRM_DELETE_PERSISTENT = """{color=#7a0000}Warning!{/color}
{size=-4}You are about to reset all persistent data, including
achievements, seen text, and preferences.{/size}\n

View File

@ -167,7 +167,6 @@ init python:
build.classify("**.db", None)
build.classify("**.zip", None)
build.classify("cache/**", None)
build.classify("cache/**", "android")
build.classify("game/saves/**", None)
build.classify("game/mods/**", None)

View File

@ -1,15 +1,28 @@
init -10 python:
init python:
if renpy.android:
settings.default("crashdefendersetting", 0)
# Attempts at fixing the texture leak plaguing
# android devices, mainly running on Android11 & Android 12.
class Android11TextureLeakFix(NoRollback):
def __init__(self, limit=100):
self.statements = 0
self.limit = limit
self.set_mode(settings.get("crashdefendersetting"))
def set_mode(self, mode):
if mode == 3:
self.limit = 15
elif mode == 2:
self.limit = 25
elif mode == 1:
self.limit = 55
else:
self.limit = 0
def __call__(self, name):
if renpy.is_init_phase():
if renpy.is_init_phase() or self.limit == 0:
return
self.statements += 1
@ -43,7 +56,11 @@ init -10 python:
renpy.display.render.free_memory()
config.statement_callbacks.append(Android11TextureLeakFix())
crashdefender = Android11TextureLeakFix()
config.statement_callbacks.append(crashdefender)
init -10 python:
if renpy.windows:
# On windows, Renpy does not support backslashes in some of its functions,