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(android): prevent ANRs, delegate them to be handled by system #14184

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
332065c
feat(android): added new methods in CalendarProxy for bulk operations
prashantsaini1 Dec 2, 2024
cc5a1ca
chore: use constant properties
prashantsaini1 Dec 2, 2024
8b1e4f3
fix: add missing properties of `scrolling` event
prashantsaini1 Dec 4, 2024
02b1daa
chore(android): add docs to new methods for Ti.Calendar.Calendar module
prashantsaini1 Dec 4, 2024
e2c4bb9
fix(android): set exitOnClose defaults to true on root window if not …
prashantsaini1 Dec 4, 2024
e67d60c
Revert "fix(android): set exitOnClose defaults to true on root window…
prashantsaini1 Dec 4, 2024
fb8ed06
fix: fix docs formatting
prashantsaini1 Dec 4, 2024
5dd1b1a
Update android/modules/calendar/src/java/ti/modules/titanium/calendar…
prashantsaini1 Dec 4, 2024
ec3fc05
Update android/modules/calendar/src/java/ti/modules/titanium/calendar…
prashantsaini1 Dec 4, 2024
d301d6e
Update android/modules/calendar/src/java/ti/modules/titanium/calendar…
prashantsaini1 Dec 4, 2024
8a452c7
Merge branch 'master' of https://github.com/prashantsaini1/titanium_m…
prashantsaini1 Dec 4, 2024
01957b9
Merge remote-tracking branch 'upstream/master'
prashantsaini1 Dec 5, 2024
569be13
fix: fix docs
hansemannn Dec 12, 2024
6ed66b5
Merge branch 'master' of https://github.com/prashantsaini1/titanium_m…
prashantsaini1 Dec 13, 2024
2ca3171
Merge remote-tracking branch 'upstream/master'
prashantsaini1 Jan 13, 2025
88efe6a
fix(android): prevent ANR and allow system to handle them
prashantsaini1 Feb 17, 2025
d5ab787
fix(android): add safe null check
prashantsaini1 Feb 17, 2025
6550761
fix(android): add safe null checks and use current thread to report r…
prashantsaini1 Feb 17, 2025
534cdde
Merge remote-tracking branch 'upstream/master' into fix/android-anr
prashantsaini1 Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ public static void dispatchException(final String title, final String message, f
}

// Handle exception with defaultExceptionHandler
instance.primaryExceptionHandler.handleException(exceptionMessage);
if (instance.primaryExceptionHandler != null) {
instance.primaryExceptionHandler.handleException(exceptionMessage);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ public boolean handleMessage(Message msg)
}
}
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public abstract class TiApplication extends Application implements KrollApplicat
private String defaultUnit;
private BroadcastReceiver localeReceiver;
private AccessibilityManager accessibilityManager = null;
private UncaughtExceptionHandler nativeExceptionHandler = null;

protected TiDeployData deployData;
protected ITiAppInfo appInfo;
Expand Down Expand Up @@ -340,12 +341,23 @@ public void loadAppProperties()
}
}

public static void handleInternalException(Throwable throwable)
{
final UncaughtExceptionHandler currentExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (currentExceptionHandler != null) {
currentExceptionHandler.uncaughtException(Thread.currentThread(), throwable);
}
}

@Override
public void onCreate()
{
super.onCreate();
Log.d(TAG, "Application onCreate", Log.DEBUG_MODE);

// Reference to android run-time exception handler to delegate exceptions properly.
nativeExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();

// handle uncaught java exceptions
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
Expand All @@ -364,6 +376,10 @@ public void uncaughtException(Thread t, Throwable e)

// throw exception as KrollException
KrollRuntime.dispatchException("Runtime Error", e.getMessage(), null, 0, null, 0, null, javaStack);

if (nativeExceptionHandler != null) {
nativeExceptionHandler.uncaughtException(t, e);
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ public void onChanged(TiActivitySafeAreaMonitor monitor)
try {
windowCreated(savedInstanceState);
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}

// set the current activity back to what it was originally
Expand All @@ -817,7 +817,7 @@ public void onChanged(TiActivitySafeAreaMonitor monitor)
try {
window.onWindowActivityCreated();
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}
}
if (activityProxy != null) {
Expand Down Expand Up @@ -1338,7 +1338,7 @@ private void dispatchCallback(String propertyName, KrollDict data)
data.put(TiC.EVENT_PROPERTY_SOURCE, this.activityProxy);
this.activityProxy.callPropertySync(propertyName, new Object[] { data });
} catch (Throwable ex) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, ex);
TiApplication.handleInternalException(ex);
}
}

Expand Down
Loading