Skip to content

fix(util): is folder writable anr#16809

Merged
alperozturk96 merged 4 commits into
masterfrom
fix/anr-folder-writable
Apr 8, 2026
Merged

fix(util): is folder writable anr#16809
alperozturk96 merged 4 commits into
masterfrom
fix/anr-folder-writable

Conversation

@alperozturk96

@alperozturk96 alperozturk96 commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Issue

ANR error caused by executing I/O on the main thread.

 #00  pc 0x000000000009f7dc  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
  #01  pc 0x0000000000201434  /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks+136)
  #02  pc 0x000000000064a824  /apex/com.android.art/lib64/libart.so (art::JNI<false>::NewStringUTF+3972)
  #03  pc 0x00000000000242a8  /apex/com.android.art/lib64/libopenjdk.so (Java_java_io_UnixFileSystem_list0+420)
  at java.io.UnixFileSystem.list0 (Native method)
  at java.io.UnixFileSystem.list (UnixFileSystem.java:402)
  at java.io.File.list (File.java:1145)
  at java.io.File.listFiles (File.java:1230)
  at com.owncloud.android.utils.FileStorageUtils.isFolderWritable (FileStorageUtils.java:795)
  at com.owncloud.android.ui.activity.UploadFilesActivity.checkWritableFolder (UploadFilesActivity.java:599)
  at com.owncloud.android.ui.activity.UploadFilesActivity.pushDirname (UploadFilesActivity.java:465)
  at com.owncloud.android.ui.activity.UploadFilesActivity.onDirectoryClick (UploadFilesActivity.java:593)
  at com.owncloud.android.ui.fragment.LocalFileListFragment.onItemClicked (LocalFileListFragment.java:179)
  at com.owncloud.android.ui.adapter.LocalFileListAdapter.lambda$onBindViewHolder$1 (LocalFileListAdapter.java:254)
  at com.owncloud.android.ui.adapter.LocalFileListAdapter.$r8$lambda$QpkUeU_0knpa_PBZ0Gk2E9oqku4 (unavailable)
  at com.owncloud.android.ui.adapter.LocalFileListAdapter$$ExternalSyntheticLambda4.onClick (D8$$SyntheticClass)
  at android.view.View.performClick (View.java:8229)
  at android.view.View.performClickInternal (View.java:8206)
  at android.view.View.-$$Nest$mperformClickInternal (unavailable)
  at android.view.View$PerformClick.run (View.java:32007)
  at android.os.Handler.handleCallback (Handler.java:1095)
  at android.os.Handler.dispatchMessageImpl (Handler.java:135)
  at android.os.Handler.dispatchMessage (Handler.java:125)
  at android.os.Looper.loopOnce (Looper.java:269)
  at android.os.Looper.loop (Looper.java:367)
  at android.app.ActivityThread.main (ActivityThread.java:9333)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:566)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:929)

Changes

  • Removes isFolderWritable FileStorageUtils.java and add inside FileUtils.java since FileUtils much smaller class.
  • Converts FileUtils.java to Kotlin to handle thread management easily and write tests easily
  • Removes unused getFilenameFromPathString function and tests
  • Adds tests for isFolderWritable
  • Instead of using listFiles which is very expensive operation, just tries to create temp dir then creates the temp file in temp dir then tries to delete all

This way in future we can slowly use our util functions inside FileUtils.kt then gain performance, safety.

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@alperozturk96 alperozturk96 added this to the Nextcloud App 33.1.0 milestone Apr 7, 2026
@alperozturk96 alperozturk96 added the performance 🚀 Performance improvement opportunities (non-crash related) label Apr 7, 2026
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/24077570029/artifacts/6304182028
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice3636
Correctness6969
Dodgy code229229
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4242
Security1616
Total436436

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/24078527579/artifacts/6304561069
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@alperozturk96 alperozturk96 merged commit 7dacbad into master Apr 8, 2026
15 of 20 checks passed
@alperozturk96 alperozturk96 deleted the fix/anr-folder-writable branch April 8, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review performance 🚀 Performance improvement opportunities (non-crash related)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants