Skip to content

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

@venkyqz

Description

@venkyqz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileOperationsRelated to file operations (e.g. moving, copying, renaming).Area-SMBRelated to SMB connections.Issue-BugRelated unexpected behavior or something worth investigating.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions