Closed Bug 776223 Opened 7 years ago Closed 6 years ago

java.lang.NullPointerException: at android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java) on Samsung devices running ICS

Categories

(Firefox for Android :: Keyboards and IME, defect, critical)

ARM
Android
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Firefox 24
Tracking Status
firefox16 --- affected
firefox17 --- affected
firefox18 --- affected
firefox19 --- affected
firefox20 --- affected
firefox21 --- wontfix
firefox22 + fixed
firefox23 --- fixed
firefox24 --- fixed

People

(Reporter: scoobidiver, Assigned: cpeterson)

References

Details

(Keywords: crash, Whiteboard: [native-crash])

Crash Data

Attachments

(2 files)

There are 11 crashes in 14.0 and 15.0 Beta. Here is a crash report: bp-9ad34ba8-3e8e-4865-911c-926eb2120719.

java.lang.NullPointerException
	at android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java:137)
	at org.mozilla.gecko.GeckoAppShell$7.run(GeckoAppShell.java:1065)
	at android.os.Handler.handleCallback(Handler.java:605)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at org.mozilla.gecko.GeckoBackgroundThread.run(GeckoBackgroundThread.java:31)

More reports at:
https://crash-stats.mozilla.com/report/list?signature=java.lang.NullPointerException%3A+at+android.content.ClipboardManager.setPrimaryClip%28ClipboardManager.java%29
This code is running on the GeckoBackgroundThread. I suspect the ClipboardManager probably wants to be called on the UI thread because nothing in GeckoAppShell.setClipboardText() looks like to could cause a NullPointerExceptionin ClipboardManager.setPrimaryClip().

https://hg.mozilla.org/releases/mozilla-aurora/annotate/e070197f4c89/mobile/android/base/GeckoAppShell.java#l1289

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/content/ClipboardManager.java#L119
Version: Firefox 14 → Trunk
I believe this problem will be fixed by bug 870333.
Status: NEW → RESOLVED
Closed: 6 years ago
Component: General → Keyboards and IME
Depends on: 870333
Resolution: --- → WORKSFORME
Resolution: WORKSFORME → FIXED
Target Milestone: --- → Firefox 24
(In reply to Chris Peterson (:cpeterson) from comment #2)
> I believe this problem will be fixed by bug 870333.
No. See bp-2a2c8059-0f05-47fa-8e9e-96b952130517.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: Firefox 24 → ---
Paste an empty string instead of null to avoid clipboard crashes. AndroidBridge::EmptyClipboard() passes null to clear the clipboard's current contents.
Assignee: nobody → cpeterson
Status: REOPENED → ASSIGNED
Attachment #751270 - Flags: review?(blassey.bugs)
It's #38 crasher in 21.0 and #6 in 22.0b1 (many duplicates).
Attachment #751270 - Flags: review?(blassey.bugs) → review+
Scoobidiver, thanks for reopening this bug so I could find the real fix! <:)

After my fix is merged to mozilla-central, I will ask to uplift the fix to Aurora 23 and Beta 22.
https://hg.mozilla.org/mozilla-central/rev/501ef1098f55
Status: ASSIGNED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 24
Comment on attachment 751270 [details] [diff] [review]
dont-paste-null.patch

[Approval Request Comment]
Bug caused by (feature/regressing bug #): 
User impact if declined: Long-standing topcrash will persist. Scoobidiver says this crash is #38 in 21.0 and #6 in 22.0b1 (with many duplicates).
Testing completed (on m-c, etc.): m-c
Risk to taking this patch (and alternatives if risky): Low risk because it is basically just adding a null check.
String or IDL/UUID changes made by this patch: N/A
Attachment #751270 - Flags: approval-mozilla-beta?
Attachment #751270 - Flags: approval-mozilla-aurora?
Attachment #751270 - Flags: approval-mozilla-beta?
Attachment #751270 - Flags: approval-mozilla-beta+
Attachment #751270 - Flags: approval-mozilla-aurora?
Attachment #751270 - Flags: approval-mozilla-aurora+
It's not fixed.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Thanks again for your diligence, Scoobidiver! <:)

I am now convinced this crash is a Samsung bug. Of the 1,252 ClipboardManager crash reports in Firefox 21, 22b1, 23a2, and 24a1 over the past 28 days, 100% of these crashes are from Samsung devices!!

According to similar reports on Samsung developer forums [1] and Google's Android issue tracker [2], the workaround is to root your phone and delete the files in /data/clipboard.

> Samsung devices running TouchWiz and Android 3.0 or higher have a fatal
> clipboard bug that can cause it to become permanently unusable until a
> factory reset. It seems to occur randomly. Whenever a user tries to copy
> something, this error occurs in the system ClipboardManager class:
>
> java.lang.NullPointerException at
> android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java:146)
>
> And the application that the user is using crashes. The only fix for this
> is to perform a factory reset or to clear the contents of /data/clipboard
> as a rooted user. Since this directory does not exist in stock Android,
> the fault is clearly with the Samsung software.

[1] http://developer.samsung.com/forum/board/thread/view.do?boardName=GeneralB&messageId=221255

[2] https://code.google.com/p/android/issues/detail?id=35732
Summary: java.lang.NullPointerException: at android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java) → java.lang.NullPointerException: at android.content.ClipboardManager.setPrimaryClip(ClipboardManager.java) on Samsung devices running ICS
Blocks: 876485
Comment on attachment 754932 [details] [diff] [review]
Catch NullPointerException from Samsung's buggy clipboard API. r=

This topcrash is actually a Samsung bug. 100% of all these 1,200+ clipboard crashes across all channels over the past 28 days are on Samsung devices!

Samsung's clipboard implementation tries to cache clipboard items in /data/clipboard, but their code will throw a NullPointerException if this directory is full. Should we limit this NullPointerException catch to Samsung devices?
Attachment #754932 - Flags: review?(blassey.bugs)
Comment on attachment 754932 [details] [diff] [review]
Catch NullPointerException from Samsung's buggy clipboard API. r=

Review of attachment 754932 [details] [diff] [review]:
-----------------------------------------------------------------

No, no need to limit this try/catch to only Samsung devices. Is it possible to clear that cache though?
Attachment #754932 - Flags: review?(blassey.bugs) → review+
(In reply to Brad Lassey [:blassey] from comment #15)
> Is it possible to clear that cache though?

Unfortunately, no. According to the discussion on the Samsung forums and Android's bug tracker, you must root the phone to delete the files in (the Samsung-specific directory) /data/clipboard.
https://hg.mozilla.org/mozilla-central/rev/1ad0d609ccd1
Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
Comment on attachment 754932 [details] [diff] [review]
Catch NullPointerException from Samsung's buggy clipboard API. r=

[Approval Request Comment]
Bug caused by (feature/regressing bug #): This is a Samsung bug. 100% of this bug's 1,200+ crashes are on Samsung devices, confirmed on Samsung's developer forum.
User impact if declined: Long-standing crash on Samsung devices.
Testing completed (on m-c, etc.): Speculative fix; I have not reproduced the bug myself.
Risk to taking this patch (and alternatives if risky): Low risk. The patch just catches a NullPointerException intermittently thrown from Samsung's clipboard API.
String or IDL/UUID changes made by this patch: N/A
Attachment #754932 - Flags: approval-mozilla-beta?
Attachment #754932 - Flags: approval-mozilla-aurora?
Comment on attachment 754932 [details] [diff] [review]
Catch NullPointerException from Samsung's buggy clipboard API. r=

Approving this speculative fix given where we are in the cycle and the low risk nature of a null check.
Attachment #754932 - Flags: approval-mozilla-beta?
Attachment #754932 - Flags: approval-mozilla-beta+
Attachment #754932 - Flags: approval-mozilla-aurora?
Attachment #754932 - Flags: approval-mozilla-aurora+
You need to log in before you can comment on or make changes to this bug.