capacitor-community / capacitor-community/admob

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

Open Beginner friendly
#427 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
296
Forks
97
Avg merge
2d 6h
Merged PRs (30d)
7

Description

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.

Contributor guide

Open the contributing guide

Research direction

Open BannerExecutor.java and inspect showBanner around line 108, where the window-insets listener is registered on the decor view. Move that listener to mAdViewLayout while preserving its existing body, then verify that the banner remains positioned correctly and the semi-transparent bar no longer appears after rotating with edge-to-edge enabled on Android 15+.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.