Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Java NullPointerException when you touch display outside of the diagram (Read 8447 times)
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Java NullPointerException when you touch display outside of the diagram
Oct 17th, 2014 at 7:31am
Print Post  
Here's the stack trace:

10-17 09:20:49.920 16381-16381/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.mindfusion.diagramming.Utilities.a(SourceFile:2348)
at com.mindfusion.diagramming.DiagramView.pointerMove(SourceFile:543)
at com.mindfusion.diagramming.DiagramView.onTouchEvent(SourceFile:385)
at android.view.View.dispatchTouchEvent(View.java:7143)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2238)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1935)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(P
honeWindow.java:1938)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow
.java:1392)
at android.app.Activity.dispatchTouchEvent(Activity.java:2408)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneW
indow.java:1886)
at android.view.View.dispatchPointerEvent(View.java:7323)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3530)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3464)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4553)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4532)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.jav
a:4628)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.jav
a:163)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4607)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4647
)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:747)
at android.view.Choreographer.doCallbacks(Choreographer.java:567)
at android.view.Choreographer.doFrame(Choreographer.java:534)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:733)

at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

This happens when I touch the display outside of the diagram area.

This is on an Acer tablet running Android 4.1.2. It's the new DroidDiagram 1.1.

I think maybe this only happens on later versions of Android - I don't think I've ever experienced it on my old Samsung Galaxy II, which runs Android 2.3.4.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Java NullPointerException when you touch display outside of the diagram
Reply #1 - Oct 20th, 2014 at 8:50am
Print Post  
We could not reproduce that, but by looking at our code we can see a null exception is possible if we receive a POINTER_MOVE action without a POINTER_DOWN preceding it. According to MotionEvent's Consistency Guarantees section that should not happen:

Motion events are always delivered to views as a consistent stream of events. For touch events, consistency implies that pointers go down one at a time, move around as a group and then go up one at a time or are canceled.

We imagine we might miss the POINTER_DOWN event if you override onTouchEvent from a custom class deriving from DiagramView and do not call the base method. Are you doing that by any chance?
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #2 - Oct 20th, 2014 at 10:27am
Print Post  
Hi, and thanks for looking into this.

No, I do not derive from DiagramView.

All of the nodes in the diagram are custom nodes, if that can have anything to do with it.

Also, I implement a listener class derived from DiagramAdapter, and containing an override for nodeClicked(). But I've just tried putting a breakpoint on the first statement in that method, and it is not getting called in the situation where the app crashes.

Then there's the weird thing about it not happening on my Samsung Galaxy II running Android 2.3.4, but it does happen on several other devices, including an HTC Desire S running Android 2.3.5.
EDIT: Just tested again - I simply can not provoke the crash on my Samsung Galaxy II, but it occurs on all other devices I have available for testing, incl. a fairly new HTC One.

If you'd like to experience it for yourself you're welcome to download the app from Merlinia's FTP server. Let me know, and I'll send you information about how to connect to the server that runs the server side of that system. I can also send you the source code, of course, but it's probably a bit difficult to do a build since several helper projects and .jar files are involved.

EDIT 2:
There is one slightly special thing I do with the Diagram object: I modify the Bounds to provide a kind of margin at the left and top. (I think I once requested this as a built-in feature.)

Code (Java)
Select All
   private static final float CPseudoMarginSize = 20f;  // Amount to offset the display by

         // Try to adjust the diagram's bounds to provide a kind of margin on the top and left
         // edges. This is necessary because there may be wall nodes along these edges, and they are
         // located at the nominal x and y coordinates of zero, which means half of the wall is
         // outside the bounds when the bounds start at 0, 0.
         if (_mindFusionDiagram.getBounds().top == 0 &&
             _mindFusionDiagram.getBounds().left == 0) {
            _mindFusionDiagram.setBounds(new RectF(-CPseudoMarginSize, -CPseudoMarginSize,
                                                   _mindFusionDiagram.getBounds().right,
                                                   _mindFusionDiagram.getBounds().bottom));
         }
 


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Java NullPointerException when you touch display outside of the diagram
Reply #3 - Oct 20th, 2014 at 10:59am
Print Post  
Does the exception happen only when you start dragging from within that margin area?
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #4 - Oct 20th, 2014 at 11:27am
Print Post  
No. It happens when I touch the display (no dragging involved) below the diagram or to the right of the diagram.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Java NullPointerException when you touch display outside of the diagram
Reply #5 - Oct 20th, 2014 at 2:58pm
Print Post  
This build should fix it:
https://mindfusion.eu/_beta/DroidDiagram.1.1.1.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #6 - Oct 21st, 2014 at 8:15am
Print Post  
YES! That's great, thank you very much.
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #7 - Oct 24th, 2014 at 6:53am
Print Post  
I wonder if you could please place a copy of this in the "client area" that doesn't show the beta version text on the diagram? Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Java NullPointerException when you touch display outside of the diagram
Reply #8 - Oct 24th, 2014 at 9:30am
Print Post  
We'll release a stable version in a couple of weeks. You can request latest build without the label from our support email address, but there's still some development done on it so don't use in production.
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #9 - Jan 9th, 2015 at 11:29pm
Print Post  
My program is finally (finally, finally!) getting installed by a customer. Is it possible for you to release a non-beta version 1.1.1 now? Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Java NullPointerException when you touch display outside of the diagram
Reply #10 - Jan 10th, 2015 at 2:00pm
Print Post  
We released it last year, you should have it on your account page at http://clientsarea.eu/
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Java NullPointerException when you touch display outside of the diagram
Reply #11 - Jan 13th, 2015 at 11:02pm
Print Post  
Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint