Skip to content
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

NullPointerException: Attempt to invoke virtual method 'boolean android.widget.FrameLayout.dispatchTouchEvent(android.view.MotionEvent)' on a null object reference #274

Open
ghost opened this issue Jan 11, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 11, 2023

Describe the bug
NullPointerException for Android when "toBack" is set to true.

NullPointerException: Attempt to invoke virtual method 'boolean android.widget.FrameLayout.dispatchTouchEvent(android.view.MotionEvent)' on a null object reference

To Reproduce
Steps to reproduce the behavior:

  1. Integrate this plugin
  2. Set "toBack" to true
  3. Running app
  4. When opening a screen that is invoking start of camera preview and user immediately clicks on screen when camera is not finished launching, app crashes

Expected behavior

App does not crash when clicking to early on screen..

Additional context

In the CameraPreview -> setupBroadcast method we invoke fragment.frameContainerLayout.dispatchTouchEvent(event);
This will crash when fragment.frameContainerLayout is null. This is not being checked accordingly. Please, check the current method below.

I think, there should be (null != fragment.frameContainerLayout) added to the if statement.

 private void setupBroadcast() {
        /** When touch event is triggered, relay it to camera view if needed so it can support pinch zoom */

        getBridge().getWebView().setClickable(true);
        getBridge()
            .getWebView()
            .setOnTouchListener(
                new View.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if ((null != fragment) && (fragment.toBack == true)) {
                            fragment.frameContainerLayout.dispatchTouchEvent(event);
                        }
                        return false;
                    }
                }
            );
    }
@DayUx
Copy link

DayUx commented May 5, 2023

I have the same issue, it's pretty annoying

@nvahalik
Copy link

Can confirm that this works for us!

@tradingproject19
Copy link

Thanks this condition fixed the issue. But I am unable to reproduce this issue. It happens sometime, I don't know why. Please comment on this thread if anyone finds the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants