Skip to content

[Bug] iOS WebView: height="100%" collapses to 0 (Android OK) — requires explicit height #156

@ElecTreeFrying

Description

@ElecTreeFrying

Environment

  • CLI: 8.9.3
  • @nativescript/core: 8.9.9
  • Android Runtime: 8.9.2
  • iOS Runtime: 8.9.4
  • Plugin(s):
        "@nativescript-community/ui-checkbox": "^2.0.12",
        "@nativescript-community/ui-material-activityindicator": "^7.2.71",
        "@nativescript-community/ui-material-snackbar": "^7.2.71",
        "@nativescript/angular": "^20.0.0",
        "@nativescript/appavailability": "^2.0.0",
        "@nativescript/biometrics": "^1.3.1",
        "@nativescript/core": "^8.9.9",
        "@nativescript/datetimepicker": "^3.0.0",
        "@nativescript/facebook": "^3.1.0",
        "@nativescript/geolocation": "^9.0.0",
        "@nativescript/google-maps": "^1.8.0",
        "@nativescript/google-signin": "^2.1.1",
        "@nativescript/secure-storage": "^4.0.1",
        "@nativescript/social-share": "^2.3.0",
  • @nativescript/angular: 20.0.0
  • Angular: 20.1.0

Describe the bug

WebView does not honor height="100%" on iOS when rendering an HTML string.

  • Android: Fills available space as expected.
  • iOS: Appears to resolve to 0 height unless given a fixed DIP height (e.g., height="100"), which shows content but makes it scrollable and not full height of the parent.

This looks like percentage height not being respected even when the parent is sized.

To Reproduce

  1. Create a minimal NS Angular app/page.
  2. Place a WebView intended to fill the remaining space:
    <GridLayout rows="auto,*" iosOverflowSafeArea="true">
      <Label row="0" text="Header"/>
      <WebView row="1" [src]="doc()" height="100%" />
    </GridLayout>
    doc = () => `
      <!doctype html>
      <html>
        <head>
          <meta charset="utf-8"/>
          <meta name="viewport" content="width=device-width, initial-scale=1"/>
        </head>
        <body>
          <p>Some content</p>
          <img src="https://via.placeholder.com/600x400" />
        </body>
      </html>`;
  3. Run on Android →WebView fills remaining space (OK).
  4. Run on iOS → WebView renders at 0 height (not visible).
  5. Change height="100%" to height="100" → content appears (scrollable), but not full parent height.

Repro also occurs if theWebView is insideStackLayout,FlexboxLayout, or with outer ScrollView removed.

Expected behavior

On iOS, <WebView height="100%"> should fill the remaining space of its parent (e.g., star row inGridLayout) similar to Android, without requiring a fixed DIP height or additional imperative sizing.

Sample project

Minimal snippet above; I can provide a repo if needed.

Additional context

  • Tried the following without success on iOS:
    • Putting the WebView in a GridLayout row="*" container.
    • FlexboxLayout with flexGrow="1".
    • RemovingScrollView wrappers so the WebView can scroll itself.
    • verticalAlignment="stretch", iosOverflowSafeArea="true", safe-area adjustments.
  • Question: Is there a known issue or platform limitation with WKWebView + percent heights in NativeScript layouts? If so, is there a recommended cross-platform pattern to haveWebView fill its parent without imperative sizing?

Logs aren’t showing runtime errors; this appears to be a layout/measurement behavior specific to iOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions