SDK-92 Fix intermittent in-app message positioning#1001
Merged
sumeruchat merged 6 commits intomasterfrom Mar 24, 2026
Merged
Conversation
joaodordio
approved these changes
Feb 18, 2026
SDK-92: In-app messages were intermittently displaying in the wrong position (e.g., bottom position messages appearing in center/top). Root cause: viewDidLayoutSubviews calls resizeWebView before the webview content finishes loading. When document.body.offsetHeight is evaluated before the DOM is ready, it returns 0 or incorrect values, causing wrong position calculations. Fix: Added webViewDidFinishLoading flag that prevents resizeWebView from executing in viewDidLayoutSubviews until after the webview finishes loading. This ensures position is only calculated when document.body.offsetHeight returns the correct value. Changes: - Added webViewDidFinishLoading flag (initially false) - Set flag to true in webView(_:didFinish:) - Guard viewDidLayoutSubviews resize logic with flag check - Added test to verify flag behavior
9df77c5 to
c9302a7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1001 +/- ##
==========================================
+ Coverage 70.75% 70.79% +0.04%
==========================================
Files 112 112
Lines 9191 9197 +6
==========================================
+ Hits 6503 6511 +8
+ Misses 2688 2686 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes intermittent positioning issues where in-app messages configured for bottom/top/center positions display in the wrong location.
Jira ticket: SDK-92
Root Cause
viewDidLayoutSubviews()callsresizeWebView()before the webview content finishes loading. Whendocument.body.offsetHeightis evaluated via JavaScript before the DOM is ready, it returns 0 or incorrect values, causing position calculations to fail.The lifecycle was:
viewDidLoad()loads HTML into webviewviewDidLayoutSubviews()called (before content ready) → calculates wrong positionwebView(_:didFinish:)called (after content ready) → recalculates, but may be too lateSolution
Added
webViewDidFinishLoadingflag that preventsresizeWebView()from executing inviewDidLayoutSubviews()until the webview finishes loading. This ensures position is only calculated whendocument.body.offsetHeightreturns accurate values.Changes
IterableHtmlMessageViewController.swift
webViewDidFinishLoadingflag (initiallyfalse)trueinwebView(_:didFinish:)viewDidLayoutSubviews()resize logic with flag checkIterableHtmlMessageViewControllerTests.swift
testWebViewFinishLoadingFlagBehavior()to verify flag lifecycleImpact
Testing
Unit tests: New test verifies the
webViewDidFinishLoadingflag behaviorManual testing: