TeamAmaze / TeamAmaze/AmazeFileManager

Potential ANR / `NetworkOnMainThread` Risk: Synchronous SMB network call in `HybridFile.exists()`

Open
#4,610 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-FileOperations Area-SMB Issue-Bug
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

Environment

  • App: Amaze File Manager (com.amaze.filemanager)
  • Branch: master
  • File: HybridFile.java
The Issue

While reviewing the HybridFile implementation, I noticed a potential main-thread blocking risk when dealing with SMB connections.

Currently, HybridFile.exists() directly creates an SmbFile and calls its exists() method synchronously:

public boolean exists() {
    boolean exists = false;
    // ...
    } else if (isSmb()) {
        try {
            SmbFile smbFile = getSmbFile(2000);
            exists = smbFile != null && smbFile.exists(); // <-- Synchronous network I/O
        } catch (SmbException e) {
            // ...
        }
    }
    // ...
    return exists;
}

Because jcifs.smb.SmbFile.exists() is a network-backed operation, it will block the calling thread while connecting, negotiating, or waiting on an unresponsive server.

The Risk & Impact

If HybridFile.exists() is ever reached via a UI-thread call path (e.g., inside an onClick, a menu callback, or a RecyclerView adapter binding), it will freeze the UI. Depending on the device and server state, this can lead to severe UI jank, ANRs, or a NetworkOnMainThreadException.

We know this module family is susceptible to this pattern, as a nearly identical issue caused crashes in the past (see Issue #3982: NetworkOnMainThreadException on HybridFile.getUsableSpace).

Next Steps / Verification Required

I have not tracked down a confirmed production path that calls this specifically on the main thread, but because this is a core utility method, it is highly vulnerable to being misused in UI callbacks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java at exists(), then trace callers from UI entry points such as onClick, menu callbacks, and RecyclerView binding. Review Issue #3982 for the related precedent; the work is done when the main-thread risk is confirmed or ruled out and the chosen handling is verified against the relevant call paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, networking, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.