-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run getGlobalVisibleRect on the main thread instead of a background thread #736
Conversation
adBaseView.getGlobalVisibleRect(rect); | ||
|
||
Handler mainHandler = new Handler(Looper.getMainLooper()); | ||
mainHandler.post(() -> adBaseView.getGlobalVisibleRect(rect)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quick search shows that there are more than 20 usages of the adBaseView
object in the BaseJSInterface
class.
I'm afraid any of them can lead to a similar crash.
I'd suggest really, hard to reproduce the current crash first, then fix it, then try to reproduce with other usages of the adBaseView
before the release. It will help to understand the curcomstanses and prevent other crashes, potentially in the same ads.
If we can't reproduce it, of course, we need to release the fix based on the assumptions, but it is better to cover as much potential cases as possible. Otherwice we will get the same crash statistic but with another method, for example: adBaseView.getGlobalVisibleRect(rect)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already looked through the usages, most are checks if null or are already called on the main/ui thread. I have not been able to reproduce though and you are correct that we need to try to reproduce first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it should fix the current crash. But I'm not sure about all other possible cases.
Ideally, since we've faced such an issue, we should wrap a managed WebView in some background-thread-safe-invocation wrapper. To make sure that all clients of the JS bridge (ad code and SDK code) can use in safely. It could be done in the scope of the separate tech debt ticket.
adBaseView.getGlobalVisibleRect(rect); | ||
|
||
Handler mainHandler = new Handler(Looper.getMainLooper()); | ||
mainHandler.post(() -> adBaseView.getGlobalVisibleRect(rect)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should release this hotfix as soon as possible, since it leads to multiple crashes right now. |
I will be merging this and the other PR's and putting out a release today. |
Closes #735