gabriel2mm commented on code in PR #1924:
URL: https://github.com/apache/cordova-android/pull/1924#discussion_r3253170517


##########
framework/src/org/apache/cordova/CordovaActivity.java:
##########
@@ -225,13 +225,25 @@ protected void createViews() {
 
             boolean isStatusBarVisible = statusBarView.getVisibility() != 
View.GONE;
             int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? 
bars.top : 0;
-            int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0;
             int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0;
             int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0;
 
+            int bottom = 0;
+            Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
+            // When in fullscreen mode, we ignore bottom system insets (like 
the navigation bar)
+            // to allow the WebView to span the entire screen and avoid being 
pushed up.
+            if (!isFullScreen) {
+                bottom = canEdgeToEdge ? imeInsets.bottom : 
Math.max(bars.bottom, imeInsets.bottom);
+            }
+
             FrameLayout.LayoutParams webViewParams = 
(FrameLayout.LayoutParams) webView.getLayoutParams();
-            webViewParams.setMargins(left, top, right, bottom);
-            webView.setLayoutParams(webViewParams);
+            // Only update layout margins if the values have actually changed.
+            // This prevents redundant layout passes and potential infinite 
layout loops
+            if (webViewParams.leftMargin != left || webViewParams.topMargin != 
top
+                    || webViewParams.rightMargin != right || 
webViewParams.bottomMargin != bottom) {

Review Comment:
   I believe this validation is highly necessary to prevent redundant updates. 
During debugging, I observed that opening the soft keyboard alone triggers this 
event multiple times with the exact same parameters. Reapplying setLayoutParams 
when the margins haven't changed forces an unnecessary re-layout on the 
WebView, which negatively impacts performance and could cause visual jitter.
   
   I also believe that the event can be triggered multiple times during system 
animations.
   
   
   Example debug code:
   
   
https://github.com/user-attachments/assets/95b9f310-c910-4821-bd1f-334ba3ed304c
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to