NetworkOnMainThreadException penalty delivery under heavy system load
0 reputation · 01 Apr 2022, 20:23 UTC
NetworkOnMainThreadException penalty delivery under heavy system load
Goal: Determine whether Android StrictMode reliably throws NetworkOnMainThreadException or delivers the configured penalty when an application performs network I/O on the main thread while the system is under heavy load.
StrictMode enforces this policy starting at API level 11 and supports penalties such as log, dropbox, dialog, and flash. The developer documentation does not guarantee that every violation is reported synchronously under load, and enforcement timing may vary across device manufacturers and Android releases. Behavior can also differ between HttpURLConnection, OkHttp, and third-party SDKs because the exception originates from the platform network stack and library adapters.
Version assumption: API level 24 or higher. Practical verification would involve logcat inspection after triggering main-thread HTTP requests; no observed result is included here.
- Does StrictMode guarantee delivery of NetworkOnMainThreadException or the selected penalty during heavy system load?
- Are there measurable differences in exception timing between HttpURLConnection and OkHttp on the same device and API level?
- Should a missing StrictMode penalty be interpreted as evidence that main-thread networking succeeded?