teads / TeadsSDK-android

Teads SDK for Android - Premium branded "outstream" ads
13 stars 6 forks source link

Video ad in WebView does not adjust position automatically #159

Closed cbeyls closed 2 years ago

cbeyls commented 3 years ago

When a video ad is inserted in a WebView, the position of the ad is not adjusted dynamically to accomodate later changes in the HTML, such as block elements being inserted or deleted in the DOM above the ad, or visibility of DOM elements being toggled.

For example, when switching the CSS visibility of a <div> block (located above the ad) from none to block, the whole content of the HTML is shifted down, but the video ad stays in its previous position, effectively hiding part of the content of the HTML page.

github-nourdine-dahmani commented 3 years ago

Hi @cbeyls Thank you for reaching us. Modification made later in the process could indeed impact the overall rendering. Unfortunately, we can't dynamically adapt the player positioning depending on element hides & moves along the experience. It is up to the publisher to place it according to its UI requirements.

As a remainder, we proposed this helper has a baseline to ease custom WebView positioning. => We do encourage you to adapt & customize it in order to place the player where you wish it to be placed (especially for custom & dynamic behavior).

Bests,

cbeyls commented 3 years ago

We are using webviewhelper in our project. We noticed that if we load both an iframe (whose height is unknown until it finishes loading) and the teads ad in the same HTML page (the iframe being located above the teads ad), then if the iframe finishes loading after the teads ad, the ad will not adjust to move down along with the rest of the content.

On iOS, this problem doesn't occur and the ad moves down along with the content. I'm suggesting to improve the code of webviewhelper on Android to handle this case like iOS does.

Also, why not distributing webviewhelper and related classes as part of the SDK ? Especially this code which allocates space for the ad after it resizes looks like it should be handled by the SDK itself:

            override fun onRatioUpdated(adRatio: Float) {
                // Some creative can resize by itself, to handle it we have to notify the webview helper
                // But unlike the ratio in onAdLoaded method, this ratio doesn't contains the footer and the header
                // To manage this behavior, a work around is to substract number to the media ratio
                webviewHelperSynch.updateSlot(if (adRatio < 1) (adRatio - 0.05f) else adRatio - 0.2f)
            }

This logic changed recently and I wasn't aware of it. Updating the SDK to the latest version did not solve the display issues we had, until I manually looked for changes in webviewhelper in this github repository and backported them in our project. It would have been easier to just upgrade the SDK version.

github-nourdine-dahmani commented 3 years ago

Hi @cbeyls, Thanks for your feedbacks, improving doc and assets is an endless rocky road. We appreciate your suggestions and will sure take them into account into future iterations.

=> We're investigating if we do have a discrepancy between iOS and Android on the resize handling.

Regarding the WebView helper file management. WebView integrations are too customizable to have a generic way to handle it. Unfortunately we can't propose a universal code that fits every app context, framework and patterns. We do not want to include it into the SDK sources and let it open to user mods. => We indeed sometimes update it when we receive interesting modification suggestions. But still it is not compatible with the SDK release cycle.

For now, we do propose this generic helper to ease WebViews integration tweaks. Perhaps we should have been more explicit about the user adaptation needs into our doc. => We'll add a notice about that.

=> We're also working on a way to improve communication about future helper updates. We already include an SDK version check into the validation tool. We'll check what can be done for the helper part.

I'll update here once I have more info about any of the points listed above.

Bests,