Skip to content

Banner ad causes semi-transparent bar artifact on orientation change (Android 15+) #427

Description

@naskovoto

On Android 15+ (API 35) with edge-to-edge enabled (setDecorFitsSystemWindows(false)), a persistent semi-transparent bar appears over the WebView content after rotating the device while a banner ad is visible. The bar matches the system's window background color and persists after the rotation completes. It does not appear if no banner has been shown.

This is a plugin issue — the bug is in BannerExecutor.java.

Image

To Reproduce

Enable edge-to-edge in your activity: WindowCompat.setDecorFitsSystemWindows(getWindow(), false)
Show a banner ad with BannerAdPosition.BOTTOM_CENTER
Rotate the device from portrait to landscape (or vice versa)
A semi-transparent bar appears and persists

Root cause
In BannerExecutor.java (line ~108), showBanner registers setOnApplyWindowInsetsListener on the decor view (getWindow().getDecorView()). This overrides the system's default DecorView.onApplyWindowInsets() implementation, which manages edge-to-edge scrim transitions during orientation changes. Even an empty listener (return insets) causes the issue — the default decor view behavior never runs.

Fix
Move the listener from the decor view to mAdViewLayout — the ad's own container. This achieves the same inset margin positioning without interfering with the system's inset handling:

// Before (line ~108, causes artifact):
View rootView = activitySupplier.get().getWindow().getDecorView();
rootView.setOnApplyWindowInsetsListener((v, insets) -> {

// After (works correctly):
mAdViewLayout.setOnApplyWindowInsetsListener((v, insets) -> {
No other changes needed — the rest of the listener body stays the same.

Smartphone

Device: Pixel emulators
OS: Android 15 (API 35), Android 16 (API 36)
Plugin version: @capacitor-community/admob@8.0.0
Capacitor: 8.x
Additional context
The issue only occurs on API 35+ where edge-to-edge is enforced. On older Android versions, setDecorFitsSystemWindows defaults to true and the decor view handles insets differently, so the artifact doesn't appear. The removeBanner method also does not clear the decor view listener, so the artifact persists even after the banner is removed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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