Skip to content

Coder Agent: Fix an Android SDK bug where tapping the chat text input field causes the chat UI to crash into a lo#23

Open
TobiasDuelli wants to merge 2 commits intomasterfrom
coder-agent/69a527f7359bb12285f80213-1772548776876-1772549209687
Open

Coder Agent: Fix an Android SDK bug where tapping the chat text input field causes the chat UI to crash into a lo#23
TobiasDuelli wants to merge 2 commits intomasterfrom
coder-agent/69a527f7359bb12285f80213-1772548776876-1772549209687

Conversation

@TobiasDuelli
Copy link

Automated changes by Gleap Coder Agent.

Task: Fix an Android SDK bug where tapping the chat text input field causes the chat UI to crash into a loading state with a blank pink/magenta screen.

After a recent SDK update, users on Android (specifically observed on Samsung Galaxy S22 Ultra running Android 16 / One UI 8.0) experience a critical UI bug in the chat widget: when tapping the text input field to type a reply, the entire chat history disappears and is replaced by an infinite loading spinner on a blank pink/magenta background, rendering the chat completely unusable.

Requirements

  1. Fix the bug where focusing/tapping the chat text input field triggers an infinite loading state that replaces the chat content
  2. Ensure chat history remains visible when the keyboard opens and the input field is focused
  3. Ensure the fix works on Android 16 (developer preview/beta) and One UI 8.0, as well as older Android versions
  4. Verify the fix handles the keyboard appearance event without triggering unnecessary data fetches or component re-initialization
  5. Ensure the chat remains functional on devices with Exynos chipsets (SM-S908E is the international Exynos variant)

Context

  • App: Birmarket (Бирмаркет) — customer support chat interface
  • Device: Samsung Galaxy S22 Ultra (SM-S908E/DS), international Exynos variant, Dual SIM
  • OS: Android 16 / One UI 8.0 (pre-release/beta build)
  • Kernel: 5.10.236-android12-9 (notable mismatch — Android 12-based kernel running on Android 16)
  • Build: BP2A.250605.031.A3.S908EXXSCGYK2
  • SDK Version: 15.1.0 (JavaScript SDK reported in environment, but the bug is on the Android native side)
  • Region: Azerbaijan (Russian locale, carriers Nar and Azercell)
  • Reporter: Ogtay Orujlu (oorujlu@competo.io)

Visual Evidence

The screen recording clearly shows the following sequence:

  1. User is in a chat conversation with support agent "Fidan" — chat history with message bubbles and quick-reply buttons is visible
  2. User taps the text input field ("Написать ответ..." / "Write a reply...")
  3. The Russian keyboard opens successfully
  4. Immediately, the chat history/message bubbles disappear entirely
  5. The content area becomes a solid pink/magenta gradient background
  6. A loading spinner appears in the center of the screen and spins indefinitely
  7. The text input field remains visible at the top, but the main chat area is blank and unusable
  8. The app remains stuck in this loading state — it never recovers

This strongly suggests that the keyboard open/input focus event is triggering a re-render, data refetch, or component reinitialization that fails to complete.

Key Insights from Discussion

  • The bug was reported after an SDK update, suggesting a regression introduced in a recent version
  • The device runs Android 16 (pre-release) with an Android 12-based kernel — this kernel/OS version mismatch could be contributing to compatibility issues
  • The support team requested specific Android version info to reproduce, confirming this may be version-specific

Implementation Notes

  • Look for keyboard/input focus event handlers in the Android chat SDK — specifically any listeners that trigger data loading, view recreation, or layout changes when the soft keyboard appears or the input field gains focus
  • Check for onConfigurationChanged, adjustResize/adjustPan window soft input mode handling, or any ViewTreeObserver layout listeners that might be triggering unintended behavior
  • Investigate recent SDK changes (the ticket title says "After SDK Update") — look at recent commits that modified chat view lifecycle, input handling, or view rendering logic
  • Check for Android 16 / API level compatibility issues — new Android versions sometimes change keyboard behavior, window insets handling, or activity lifecycle callbacks
  • Look at the loading state management — the spinner appearing suggests a loading flag is being set to true but never resolved. Check for race conditions or failed promises/callbacks in the chat message loading flow
  • Test with WindowInsetsCompat handling — Android 16 may have changes to how keyboard insets are reported, which could break existing layout adjustment logic
  • The kernel mismatch (android12 kernel on Android 16) may cause unexpected behavior with native components — consider adding defensive checks for OS version detection

… field causes the chat UI to crash into a loading state with a blank pink/magenta screen.

After a recent SDK update, users on Android (specific
Copilot AI review requested due to automatic review settings March 3, 2026 14:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent the Gleap Android chat UI (WebView-based) from resetting into a blank loading state when the soft keyboard opens / input is focused, by avoiding Activity recreation on certain configuration changes and improving WebView state restoration.

Changes:

  • Adjusted soft keyboard handling behavior and added an explicit onConfigurationChanged override to avoid Activity recreation.
  • Refactored WebView initialization to separate “settings/clients/bridge setup” from “URL load” and altered the saved-state restore flow.
  • Expanded android:configChanges for GleapMainActivity to keep the WebView alive across more configuration changes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
gleap/src/main/java/io/gleap/GleapMainActivity.java Refactors WebView init/restore and adds configuration-change handling to prevent chat state loss when keyboard opens.
gleap/src/main/AndroidManifest.xml Expands configChanges so the Activity won’t be recreated on more configuration changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +300 to +302
if (restored == null) {
// restoreState failed — fall back to a full reload.
webView.loadUrl(url);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the savedInstanceState != null path you call initBrowserSettings() (which sets the WebView INVISIBLE) and then webView.restoreState(...), but if restoreState succeeds there is no native code path that hides R.id.loader / shows the WebView (the only hide/show is triggered by the JS "ping" message). If the restored page does not re-emit that ping, the UI can remain stuck in an infinite loader/blank state after process recreation. Consider explicitly showing the WebView / hiding the loader after a successful restore, or triggering a reload/timeout fallback when the ping isn’t received.

Suggested change
if (restored == null) {
// restoreState failed — fall back to a full reload.
webView.loadUrl(url);
if (restored == null || restored.getSize() == 0) {
// restoreState failed — fall back to a full reload.
webView.loadUrl(url);
} else {
// Successfully restored a previous page. Ensure that the
// WebView is visible and the loader is hidden, since the
// restored content might not re-emit the JS "ping".
webView.setVisibility(View.VISIBLE);
View loader = findViewById(R.id.loader);
if (loader != null) {
loader.setVisibility(View.GONE);
}

Copilot uses AI. Check for mistakes.
@@ -308,6 +324,15 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
webView.restoreState(savedInstanceState);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webView.restoreState(savedInstanceState) is invoked in the webView.post(...) runnable (saved-state branch) and again in onRestoreInstanceState(). Restoring twice can lead to redundant work and can overwrite state after clients/settings have been attached, making behavior harder to reason about. Consider choosing a single restore location (either rely on onRestoreInstanceState or gate the second call with a flag).

Suggested change
webView.restoreState(savedInstanceState);
// WebView state is restored in onCreate via the savedInstanceState branch.

Copilot uses AI. Check for mistakes.
<activity
android:name="io.gleap.GleapMainActivity"
android:configChanges="orientation|screenSize"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden|screenLayout|smallestScreenSize|uiMode|navigation|density"
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The activity now claims to handle a very broad set of configChanges (including density and uiMode). When these are listed, Android will not recreate the Activity and will also not automatically re-apply updated resources for those configuration changes, which can cause incorrect theming/scaling after dark-mode changes or display-size/density changes. Consider narrowing this list to only the minimum needed to prevent the keyboard-related recreation (and leave other changes to the default recreation behavior).

Suggested change
android:configChanges="orientation|screenSize|keyboard|keyboardHidden|screenLayout|smallestScreenSize|uiMode|navigation|density"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"

Copilot uses AI. Check for mistakes.
… infinite loading spinner when the keyboard opens after tapping the text input field.

After a recent SDK update, on a Samsung Galaxy S22 Ultra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants