Skip to content

Potential ANR / main-thread blocking risk #2931

@venkyqz

Description

@venkyqz

Environment

  • App: TIC-80 (com.nesbox.tic)
  • Branch checked: main
  • File: build/android/app/src/main/java/com/nesbox/tic/TICFileReceiver.java:76
  • Verified commit: f133009adfac866c24d8259b6b4b24ce85abe330

The Issue

While reviewing TICFileReceiver.SaveFile() → ContentResolver-query, I noticed a potential main-thread blocking risk around android.content.ContentResolver#query(android.net.Uri,java.lang.String[],java.lang.String,java.lang.String[],java.lang.String).

The latest source still operates synchronously:

73:             path = uri.getPath();
74:         } else if("content".equals(scheme)) {
75:             ContentResolver contentResolver = context.getContentResolver();
76:             Cursor cursor = contentResolver.query(uri, new String[] { MediaStore.MediaColumns.DATA }, null, null, null);
77:             if (cursor != null) {
78:                 cursor.moveToFirst();
79:                 path = cursor.getString(0);
80:                 cursor.close();
81:             }

android.content.ContentResolver#query(android.net.Uri,java.lang.String[],java.lang.String,java.lang.String[],java.lang.String) can block the calling thread. At the same time, Android resolves a provider, opens a stream, performs database work, contacts account services, touches storage, or waits on remote I/O, depending on the API and URI/backend involved.

The Risk & Impact

If this method is reached from a UI-thread path, the operation can cause visible jank, StrictMode violations in debug builds, or an ANR when the provider/backend is slow, blocked, or unreachable. I am phrasing this as a source-level risk because I verified the current source pattern but did not run an on-device reproduction.

Current source path

<com.nesbox.tic.TICFileReceiver: java.lang.String SaveFile(android.net.Uri)>
  -> android.content.ContentResolver#query(android.net.Uri,java.lang.String[],java.lang.String,java.lang.String[],java.lang.String)

Verification

I checked the latest upstream source at f133009adfac866c24d8259b6b4b24ce85abe330 and found the sensitive operation still present in build/android/app/src/main/java/com/nesbox/tic/TICFileReceiver.java. This report is based on source-level inspection, not runtime reproduction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions