android_sdk icon indicating copy to clipboard operation
android_sdk copied to clipboard

Event tracking does not work in web view.

Open jsungh88 opened this issue 6 years ago • 11 comments

I applied the adjust event to the webview. However, I cannot check the test console. The following error appears when the page is over.

E / Adjust: Application context missing. Call AdjustBridge.setApplicationContext before

Why is the event checking not related to the above log?

jsungh88 avatar Mar 23 '20 10:03 jsungh88

Hi @jsungh88

Sorry for a bit delayed answer. Did you complete all the steps from README when it comes to setting up bridge in native part of your app?

uerceg avatar Apr 01 '20 08:04 uerceg

Hi again, I suppose I has found couple bugs related to this question in AdjustBridge for android. Most issues id related to re-creation of Activity, like rotation or second start of the same activity.

  1. There is an memory leak in AdjustBridgeInstance. You hold the webview link for the all time, and never release it. It's completely wrong. In your case Activity cannot be destoyed after user closes it. And there is no way to release webview reference from AdjustBridgeInstance.
  2. The method registerAndGetInstance() from AdjustBridge works fine only for the first time. After second call of it the webview is not changed, as we have an instance of AdjustBridgeInstance. It's ok, and we have setWebView() to changed it, but it has a bug. AdjustBridgeInstance.setWebView() does not attach JS Interface to new webview, so any code from html/js part won't work correctly after this call.

How to reproduce these issues:

  1. Use AdjustBridge in any way as said in documentation.
  2. Close Activity and start it again (or just rotate activity - it will be recreated).
  3. Check results.

evgentset avatar Apr 13 '20 15:04 evgentset

@evgentset

Thanks for these findings and detailed explanations, really useful! We'll check this out and redo the bridge in accordance to your advices. Hopefully this will be part of next SDK update. Will keep you posted!

uerceg avatar Apr 23 '20 00:04 uerceg

Thank you, I was happy to help.

evgentset avatar Apr 23 '20 12:04 evgentset

Actually, the issue more complicated. For example, It may be reproduced in cases when user have 2 different WebView, like 2 fragments with WebViews and so on.

evgentset avatar Apr 23 '20 13:04 evgentset

I think to fix this issue you need to provide possibility to chnage webview somehow (and set it to null). Or even better, you can save array of WebViews and release them in proper time (onStop or onDestroy maybe). Anyway, It's up to you how to fix it.

evgentset avatar Apr 23 '20 15:04 evgentset

@uerceg Any news on this?

Would be great if a fix for the issues pointed out by @evgentset could land in the next release. I burned a complete day debugging why my app was not tracking correctly just to figure out that this is a bug in the Adjust SDK. Adding the bridge only works once. So if there is more than one web view or if the web view needs to be recreated there is no tracking at all and the javascript ends up with an error because of the missing AdjustBridge object.

Phobetor avatar May 20 '20 20:05 Phobetor

Hey @Phobetor

Sorry for delay on our end, we'll be adding fix for this in upcoming bridge updates. Will keep you posted.

uerceg avatar May 20 '20 21:05 uerceg

Hello @uerceg

Great to hear that. Thanks!

Phobetor avatar May 20 '20 21:05 Phobetor

Hey guys,

Today we released v4.22.0 update where we tried to address this issue.

Please give it a shot and let us know if it worked for you. We have extended bridge API and also updated README instructions a bit, so make sure to check those as well.

Looking forward to hearing back from you.

Cheers

uerceg avatar May 29 '20 20:05 uerceg

In case issue still persists, feel free to reopen/comment.

uerceg avatar Aug 04 '20 22:08 uerceg