63

I have built app in which I integrate YouTube API and it is working fine without any crash but on Fabric I checked some crash whis is ipf.onFilterTouchEventForSecurity. Here is the full logs of the crash:

java.lang.NullPointerException: 
  at ipf.onFilterTouchEventForSecurity(ipf.java:115)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2351)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2876)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
  at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2840)
  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1853)
  at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
  at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2801)
  at android.view.View.dispatchPointerEvent(View.java:10246)
  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5447)
  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5283)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4882)
  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4939)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7429)
  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7298)
  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7259)
  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7539)
  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
  at android.os.MessageQueue.nativePollOnce(MessageQueue.java:0)
  at android.os.MessageQueue.next(MessageQueue.java:323)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:7325)
  at java.lang.reflect.Method.invoke(Method.java:0)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I know that this issue is not because of code but I need to prevent crashing.

Here is list of devices on which I am facing issue:

  1. Samsung Galaxy J7 (j7elte), 1536MB RAM, Android 6.0
  2. Xiaomi Redmi Note 3 (kenzo), 2048MB RAM, Android 6.0
  3. Lenovo TB3-710F (TB3-710F), 1024MB RAM, Android 5.0
  4. Xiaomi Redmi 3S (land), 2048MB RAM, Android 6.0
  5. LeTV Le 2 (le_s2_ww), 3072MB RAM, Android 6.0
  6. LGE LG Stylus2 4G (ph2), 2048MB RAM, Android 6.0
  7. Infocus M2_3G (G10), 10124MB RAM, Android 4.4
Faisal Shaikh
  • 3,900
  • 5
  • 40
  • 77
  • Did you try **disabling** touch filtering for security. From the docs `To enable touch filtering, call setFilterTouchesWhenObscured(boolean) or set the android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework will discard touches that are received whenever the view's window is obscured by another visible window. As a result, the view will not receive touches whenever a toast, dialog or other window appears above the view's window.` – pellucide Jul 18 '17 at 17:19
  • @pellucide NO, In my code I never used it. – Faisal Shaikh Jul 18 '17 at 17:22
  • All the phones you listed probably have some custom code for security filtering of touches. Because I could not find a file named ipf.java in android source. – pellucide Jul 18 '17 at 17:27
  • So what should I do to prevent this? – Faisal Shaikh Jul 18 '17 at 17:30
  • if you can find the layout/view that is causing this crash, then add `android:filterTouchesWhenObscured=false` to it. – pellucide Jul 18 '17 at 17:40
  • 4
    Hi Faisal, can you please tell how you solved it or how to reproduce this bug? I got the same bug – Maor Cohen Jan 10 '18 at 23:19
  • 2
    @ErezShmiel Sorry, Issue not resolved yet. – Faisal Shaikh Jan 11 '18 at 08:08
  • Had tried android:filterTouchesWhenObscured using both with true and false value, but app still crashes – a.r. Sep 12 '18 at 11:09
  • I have a Fragment extending YouTubePlayerSupportFragment which is used with a viewpager. On scrolling fast this crash occurs. I don't know how to fix this. Any help will be appreciated. – a.r. Sep 12 '18 at 11:11
  • This issue is not resolved yet. – Faisal Shaikh Sep 12 '18 at 12:33
  • @FaisalShaikh `android:filterTouchesWhenObscured` didn't work for you? I'm also facing another issues with Android YouTube Player: https://github.com/youtube/yt-android-player/issues/21 This library has a lot of issues – user25 Jan 05 '19 at 22:07
  • @FaisalShaikh already did it – user25 Jan 05 '19 at 22:10
  • I also opened an issue at official github repository: https://github.com/youtube/yt-android-player/issues/22 – user25 Jan 05 '19 at 22:19
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Izhan Ali Apr 24 '21 at 23:22
  • 1
    You wrote `I know that this issue is not because of code` OF COURSE is about your code. A `NullPointerException` is thrown because YOUR CODE is using an object that is not instantiated. Either you call some method to get the object and the return object is null (because YOUR CODE failed to pass correct/valid parameters) or YOUR CODE declared an object and YOUR CODE used it before it was constructed. That is basically what an NPE is. – hfontanez Jun 03 '21 at 02:17
  • @hfontanez it seems you have not checked the log. – Faisal Shaikh Jun 03 '21 at 14:09
  • 1
    @FaisalShaikh I checked the log in detail. BUT, I don't need to check the log because I know EXACTLY what a `NullPointerException` is. I suggest you read Izan Ali's comment and click on the link he provided. – hfontanez Jun 04 '21 at 18:47
  • Already checked it. – Faisal Shaikh Jun 14 '21 at 09:03
  • Can you please __post sources for class `ipf.java`__. Especially its initialization and its line 115 would shed light on the NPE cause or erroneous statement. Because `ipf` seems to be a TouchEvent listener (tells the `on...` method called by `ViewGroup.dispatchTouchEvent`). – hc_dev Jul 13 '21 at 16:15
  • you can post your comment as an answer because this project is discontinued and can not make any changes in code. – Faisal Shaikh Jul 13 '21 at 21:40
  • Check that you must be doing an operation over a null value. This will always generate NPE. e.g. a-null-expression.anyMethodCall(); Verify that whatever expression is before the dot must not be null at the time anyMethodCall() is invoked. – Akash Verma Jun 12 '21 at 10:49

1 Answers1

1

I am not able to reproduce it but there are several things you can try:

If possible try adding android:filterTouchesWhenObscured=false as pellucide suggested from the docs:

Specifies whether to filter touches when the view's window is obscured by another visible window. When set to true, the view will not receive touches whenever a toast, dialog or other window appears above the view's window. Refer to the View security documentation for more details.

May be a boolean value, such as "true" or "false".

Otherwise, you can try overriding the dispatch method of your root view and place a try catch there, you can use it as a custom Component if needed.

@Override
void dispatchTouchEvent(MotionEvent event){
    try{
        super.dispatchTouchEvent(event);
    }
    catch (Exception e){
        e.printStackTrace();
    }
}
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • 1
    it's not possible, `YouTubePlayerView` is final class, now way to subclass it and override any methods – user25 Nov 19 '20 at 12:41