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

Fix editor_doc_cache locked by adb process on editor startup #97000

Conversation

Hilderin
Copy link
Contributor

I was able to reproduce the problem consistently under the following conditions:

  • The Godot Editor can be either self-contained or not.
  • Android Export needs to be configured in the Editor Settings.
  • The project must have an Android Export setup.
  • There needs to be an older version of editor_doc_cache-4.4.res in the cache folder:
    • Not self-contained: C:\Users\[user]\AppData\Local\Godot
    • Self-contained: [editorpath]\editor_data\cache
  • Start the project. While adb is running, the EditorHelp tries to rewrite the editor_doc_cache-4.4.res on disk and fails.

I tried reproducing the problem by starting adb in a loop in PowerShell and writing to editor_doc_cache-4.4.res in another PowerShell script but was never able to trigger the issue. I also changed the working directory when starting adb.exe in OS_Windows::execute without success. I still don't understand why adb locks this particular file only when started from Godot.

The fix was to postpone the first adb call until after the first scan is completed by adding a check for EditorNode::get_singleton()->is_editor_ready() in EditorExportPlatformAndroid::_check_for_changes_poll_thread. In any case, it wasn't particularly useful to call adb so early, even before the editor is ready.

Here is a small MRP project I used to reproduce the issue:
test-godot-export-android.zip

Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

This may be a useful pattern to propagate as not all logic need to run on start.

@m4gr3d
Copy link
Contributor

m4gr3d commented Sep 14, 2024

@Hilderin does this fix need to be picked in 4.3?

@Hilderin
Copy link
Contributor Author

@m4gr3d I'm not sure. Technically, this should probably occurs only dev builds. Once to editor_doc_cache is generated for a Godot version, it does not need to be regenerated. Also, I did not find the source of the issue. It's may be caused by #91902 which is not in 4.3 I think. So, it's your call, the fix should work perfectly in 4.3 but I'm not even sure the problem exists in 4.3.

@m4gr3d m4gr3d added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Sep 14, 2024
@m4gr3d
Copy link
Contributor

m4gr3d commented Sep 14, 2024

I've added the pick request; the update is straightforward enough and an improvement to the logic to warrant it.

@akien-mga akien-mga changed the title Fix editor_doc_cache locked on editor startup Fix editor_doc_cache locked by adb process on editor startup Sep 14, 2024
@akien-mga akien-mga merged commit f91c1a7 into godotengine:master Sep 16, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.3.1.

@akien-mga akien-mga removed the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

editor_doc_cache errors on editor startup
4 participants