Skip to content

Loading patch PCK on Android with big project is slow #102998

Closed
@mihe

Description

@mihe

Tested versions

Reproducible in: 4.4.beta [93d2706]

System information

OnePlus 8T, Android 14

Issue description

When loading patch PCKs on Android currently, it seems to take a long time to load the first patch when you have many files in the project, which upon investigation seems to stem from the changes made in #90425.

When profiling the MRP (consisting of 5000 barebones scene files) through Android Studio it would seem that it spends about 30 seconds (on my OnePlus 8T) in PackedSourceDirectory::try_open_pack, which is what gets run (here) when you first load a non-main pack.

More specifically, it seems to spend a lot of time dealing with android::ZipAssetsProvider when doing things like DirAccessJAndroid::dir_exists as part of DirAccess::open and DirAccessJAndroid::current_is_dir as part of DirAccess::get_directories.

Here's what the flame graph of the MRP's startup looks like:

Image

Here's a bottom-up view:

Image

Here's a zoomed in view of a few DirAccess::get_directories calls:

Image

Here's a zoomed in view of a few DirAccess::open calls:

Image

Steps to reproduce

I've included a patch PCK in the project, under patches/patch.pck. All it does is change the label in main.tscn to say "Patched" instead of "Not patched".

I've also included the script (generate.py) used to generate the scene files under generated_scenes.

  1. Open the MRP
  2. Deploy it on an Android device
  3. Note the time it takes before you're shown main.tscn

Minimal reproduction project (MRP)

android-patch-performance.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Release Blocker

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions