Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException on Meizu devices in Editor.updateCursorPositionMz

Lately, there have been crashes on my Android app, on Meizu devices only (M5c, M5s, M5 Note). Android version: 6.0.

Here is the full stack trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.text.Layout.getLineForOffset(int)' on a null object reference    at android.widget.Editor.updateCursorPositionMz(Editor.java:6964)    at android.widget.Editor.updateCursorsPositions(Editor.java:1760)    at android.widget.TextView.getUpdatedHighlightPath(TextView.java:5689)    at android.widget.TextView.onDraw(TextView.java:5882)    at android.view.View.draw(View.java:16539)    at android.view.View.updateDisplayListIfDirty(View.java:15492)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)    at android.view.View.updateDisplayListIfDirty(View.java:15443)    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:286)    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:292)    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:327)    at android.view.ViewRootImpl.draw(ViewRootImpl.java:3051)    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2855)    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2464)    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1337)    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6819)    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)    at android.view.Choreographer.doCallbacks(Choreographer.java:696)    at android.view.Choreographer.doFrame(Choreographer.java:631)    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:880)    at android.os.Handler.handleCallback(Handler.java:815)    at android.os.Handler.dispatchMessage(Handler.java:104)    at android.os.Looper.loop(Looper.java:207)    at android.app.ActivityThread.main(ActivityThread.java:5969)    at java.lang.reflect.Method.invoke(Method.java)    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:830)    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:720) 

There is no direct relation to my code (even in other threads' stracktraces). I only know that it happens everytime in a Fragment in which there are TextViews. It might be happening when a TextView is gaining focus but I have no way of being sure. Of course I cannot reproduce the bug, unless I buy a Meizu.

Also, since the top method is called updateCursorPositionMz, it looks to me like this may be an internal issue in Meizu's FlymeOS ("Mz" = "Meizu"?).

Has anyone already had this issue, knows the cause and how to fix it?

Thanks.

like image 674
Turboblaster Avatar asked Aug 17 '18 08:08

Turboblaster


2 Answers

Update (Aug. 8, 2019)

As @andreas-wenger, @waseefakhtar and @vadim-kotov mentioned, the fix is now included from com.google.android.material:material:1.1.0-alpha08 onwards.

Old answer

Finally I had the chance to put my hands on a Meizu. As I thought, the crash occurs every time the user clicks on a field to get the focus.

In my case, I had some android.support.design.widget.TextInputEditText inside TextInputLayouts. Simply replacing these TextInputEditTexts with AppCompatEditTexts fixed the problem, like so:

<android.support.design.widget.TextInputLayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:hint="...">      <android.support.v7.widget.AppCompatEditText         android:layout_width="match_parent"         android:layout_height="wrap_content"/>  </android.support.design.widget.TextInputLayout> 

The behavior remains the same (since TextInputEditText extends AppCompatEditText). I still haven't found the root cause of the problem though.

like image 114
Turboblaster Avatar answered Sep 21 '22 14:09

Turboblaster


This was just fixed in the material components for Android lib, see: https://github.com/material-components/material-components-android/pull/358

like image 45
Andreas Wenger Avatar answered Sep 17 '22 14:09

Andreas Wenger