Skip to content

Fix fatal crash in in-app popup WebView initialization#1026

Closed
franco-zalamena-iterable wants to merge 1 commit intomasterfrom
fix/1013-fatal-inapp-popup-exception
Closed

Fix fatal crash in in-app popup WebView initialization#1026
franco-zalamena-iterable wants to merge 1 commit intomasterfrom
fix/1013-fatal-inapp-popup-exception

Conversation

@franco-zalamena-iterable
Copy link
Copy Markdown
Contributor

@franco-zalamena-iterable franco-zalamena-iterable commented Apr 7, 2026

Summary

  • Adds explicit catch for AndroidRuntimeException in createWebViewSafely() to handle WebView provider failures (e.g., WebView package being updated or unavailable)
  • Adds catch for Error to handle rare native library loading failures (e.g., UnsatisfiedLinkError)
  • Gracefully dismisses the in-app dialog and logs the error instead of crashing the app

Test plan

  • Test in-app popup display on devices with working WebView
  • Verify crash is caught gracefully when WebView is unavailable

🤖 Generated with Claude Code

Add explicit catch for AndroidRuntimeException in createWebViewSafely()
to handle the case where the WebView package is being updated or is
unavailable (WebViewFactory.getProvider throws InvocationTargetException
wrapped in AndroidRuntimeException). Also catch Error for rare cases
where native WebView libraries fail to load (e.g., UnsatisfiedLinkError).

The dialog is gracefully dismissed instead of crashing the app.

Fixes #1013

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@franco-zalamena-iterable
Copy link
Copy Markdown
Contributor Author

PR Analysis

Problem: The app crashes with AndroidRuntimeException (wrapping InvocationTargetException) when creating a WebView in IterableInAppFragmentHTMLNotification.onCreateView(). This happens when the system WebView package is being updated or is unavailable. The crash was reported against SDK 3.6.5 and 3.6.6.

Ideal fix plan:

  • In SDK 3.6.5, new IterableWebView(context) was called directly in onCreateView with no try-catch — any WebView initialization failure would crash the app. This was the real bug, and it was already fixed in PR [SDK-368] Fix in-app creation causing crash due to problems with webview #999 (commit 6662d7dc7b) which introduced createWebViewSafely() wrapping the constructor in a try-catch for Resources.NotFoundException and RuntimeException.
  • Since AndroidRuntimeException extends RuntimeException, the existing catch (RuntimeException e) block in the current createWebViewSafely() already catches the exact exception in the issue's stack trace. The issue as reported is already resolved on the current main branch.
  • No additional code changes are strictly needed to fix the reported crash.

What the PR did:

  • Added an explicit catch (AndroidRuntimeException e) block before the existing catch (RuntimeException e) — this gives a more specific log message but does not change behavior since RuntimeException already catches it
  • Added a catch (Error e) block to handle hypothetical UnsatisfiedLinkError and similar — defensive but unrelated to the reported issue
  • Added a private static final String TAG field to IterableWebView.java that is never used in the diff

Assessment:

  • Root cause identified: partially — the PR correctly identifies that AndroidRuntimeException from WebView init needs to be caught, but does not acknowledge that the existing catch (RuntimeException e) already handles it. The real root cause (no try-catch at all in 3.6.5) was already fixed in PR [SDK-368] Fix in-app creation causing crash due to problems with webview #999.
  • Fix correctness: correct but redundant — the added catch blocks do not change runtime behavior for the reported crash. The AndroidRuntimeException catch is purely cosmetic (better log message). The Error catch is speculative defense-in-depth.
  • Missed: the PR does not recognize that this issue is already resolved on the current codebase. It would be worth closing the issue as fixed (by PR [SDK-368] Fix in-app creation causing crash due to problems with webview #999) rather than adding redundant catch blocks.
  • Wrong assessment: the PR implies this crash can still occur on current code, but createWebViewSafely with its RuntimeException catch already prevents it.
  • Tests: not strictly needed — the fix is a no-op relative to the existing code. If anything, a test confirming createWebViewSafely returns null (and doesn't crash) when WebView init throws AndroidRuntimeException would validate the existing behavior, but that was the responsibility of PR [SDK-368] Fix in-app creation causing crash due to problems with webview #999.
  • Unused code: TAG field added to IterableWebView.java is not referenced anywhere in the diff.

@franco-zalamena-iterable franco-zalamena-iterable deleted the fix/1013-fatal-inapp-popup-exception branch April 8, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant