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

Crash when pasting text on Samsung Devices running Android 8 #8827

Closed
jkmassel opened this issue Dec 19, 2018 · 15 comments
Closed

Crash when pasting text on Samsung Devices running Android 8 #8827

jkmassel opened this issue Dec 19, 2018 · 15 comments

Comments

@jkmassel
Copy link
Contributor

jkmassel commented Dec 19, 2018

It appears we're getting a crash specific to Samsung devices with Android 8.

The relevant bits of the stack trace:

Fatal Exception: java.lang.IndexOutOfBoundsException: 51, -49
       at android.text.PackedIntVector.deleteAt(PackedIntVector.java:222)
       at android.text.DynamicLayout.reflow(DynamicLayout.java:317)
       at android.text.DynamicLayout.-wrap0(Unknown Source)
       at android.text.DynamicLayout$ChangeWatcher.reflow(DynamicLayout.java:750)
       at android.text.DynamicLayout$ChangeWatcher.onSpanChanged(DynamicLayout.java:779)
       at android.text.SpannableStringBuilder.sendSpanChanged(SpannableStringBuilder.java:1292)
       at android.text.SpannableStringBuilder.sendToSpanWatchers(SpannableStringBuilder.java:647)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:577)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:504)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:502)
       at android.widget.TextView.pasteClipBoardData(TextView.java:673)
       at android.widget.TextView.-wrap8(Unknown Source)
       at android.widget.TextView$TextViewClipboardEventListener$1.run(TextView.java:581)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6938)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

The android.widget.TextView.pasteClipBoardData part seems like the main issue AFAICT.

reference: 5a8aafe48cb3c2fa635d5605-fabric
marked as high priority as it's happening ~40 times/day and affecting ~1000 users

@marecar3
Copy link
Contributor

marecar3 commented Jan 10, 2019

Steps to reproduce:

  1. Make sure you have Samsung device with Android 8.x
  2. Install latest WPAndroid app
  3. Login etc..
  4. Close the app and open Chrome
  5. Visit ipsum.com
  6. Copy random paragraph with Line Break included on the end of paragaph
  7. Reopen the WPAndroid app
  8. Make sure that Gutenberg is disabled
  9. Click on New Post
  10. Hold down finger over the screen until a menu with: PASTE, CLIPBOARD doesn't show up.
  11. Click on CLIPBOARD
  12. Choose lorem ipsum text from CLIPBOARD

Result : App will crash

Tested with: Galaxy Tab A (2016), Android 8.1
App version : alpha: 144

cc: @hypest @rachelmcr @daniloercoli @jkmassel

@marecar3
Copy link
Contributor

Update :

Also reproduced on Samsung Galaxy S9, Android 8.0 from browserstack.com account
App version : alpha: 144

@daniloercoli
Copy link
Contributor

This seems to be a duplicate of #7790

@marecar3 Would you mind to close the other ticket (if both report the same error - I think yes)?

@marecar3
Copy link
Contributor

Thanks @daniloercoli ! I have closed that one.

@marecar3
Copy link
Contributor

marecar3 commented Jan 15, 2019

As I need to get back to gb-mobile, I will leave the summary of my work here.

Bug summary:

Samsung devices has an option to paste the text from CLIPBAORD ListView which is unique functionallity comparing to other products. We have a line of code here : https://github.com/wordpress-mobile/AztecEditor-Android/blob/d570acad6c7d9eed029bb324aa1b78a94a82dce6/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt#L1378
which will detect copy/paste/cut from Android devices, but it WON'T detect the paste action from CLIPBOARD List view on Samsung devices.

Test Case:
If user creates a new post and paste the text which has <br> on the end of the text, app will crash.

Problem
How to detect PASTE action on Samsung devices.

Here are the notes which I have written while trying to solve above problem.

Notes:

Let me know if you have some questions while working on this one.

@marecar3 marecar3 removed their assignment Jan 15, 2019
@designsimply
Copy link
Contributor

reference: 5a8aafe48cb3c2fa635d5605-fabric marked as high priority as it's happening ~40 times/day and affecting ~1000 users

Noting that this crash is still happening in 11.9 and happened overall 1189 times (~40 times a day) for 440 users from Feb 14 - Mar 14, 2019.

@daniloercoli daniloercoli self-assigned this Mar 18, 2019
@malinajirka
Copy link
Contributor

This seems a bit similar to #8828.

Since we are able to replicate this issue, I'd suggest trying to disable the HardwareAcceleration ->if it fixes the crash, I believe we can merge these two tickets together. Simply add android:hardwareAccelerated="false" to application tag in AndroidManifest.xml. cc @daniloercoli

@daniloercoli
Copy link
Contributor

This issue is happening when you use the Samsung custom clipboard. Not happening if you use the standard Paste action. It could be the same issue, but we've a way to intercept the custom paste and stop the action before the crash.

Setting android:hardwareAccelerated="false" in the manifest is a no go, since it will slow down the editor for all users. We've already investigated this way with @hypest and decided to not follow that path. We may need to release a custom version of the app for those Samsung devices / Android versions only, but this will mean we need to release the app twice on the store.

@malinajirka
Copy link
Contributor

malinajirka commented Mar 19, 2019

I'm sorry for not being clear - I wasn't suggesting we should disable the hardwareAcceleration in the manifest in production. I suggested it only to test whether it fixes the crash so we can decide whether to merge the issues or not.

I just want to make sure we won't release two fixes for both issues even though one fix would be enough. However, since it seems the fix for 8828 won't be merged any time soon if ever, fixing this issue makes sense.

@daniloercoli
Copy link
Contributor

Fixed in wordpress-mobile/AztecEditor-Android#795!
(Or we tried to fix it :))

@designsimply
Copy link
Contributor

A user running WP 13.0.1 on a Samsung SM-A520F device with Android 8 is reporting seeing the following message when they try to paste content into the visual editor (they checked both Aztec and the block editor).

Sorry, this feature is disabled on Android 8. Please use the Paste action instead.

Screenshot_20190821-121645_WordPress

To double check, is this the expected behavior? If so, I think the best advice for the user will be to paste in HTML Mode or upgrade to the latest version of Android if at all possible. Do you agree?

(internal reference: 2291211-zen)

@malinajirka
Copy link
Contributor

To double check, is this the expected behavior?

They should see both options "Clipboard and Paste". It seems they see only "Clipboard", which doesn't work as expected and hence is disabled. I'm not sure why they don't see regular "Paste" 🤷‍♂.

If so, I think the best advice for the user

Tbh I'm not sure:D. I think the feature is disabled in both visual and html editors. Newer version of Android isn't officially supported :(.

@daniloercoli any ideas?

@sentry-io
Copy link

sentry-io bot commented Nov 25, 2019

Sentry issue: WORDPRESS-ANDROID-8W

@malinajirka
Copy link
Contributor

malinajirka commented Nov 26, 2019

@jd-alexander Good find on the related issue ;). Since the new crash in Sentry seems to be happening only on Android 7, I'd consider creating a brand new issue with a link to this issue. Another option is to re-open this issue and update its title, but a lot of the comments might be confusing since they are explicitly mentioning Android 8. Wdyt?

@jd-alexander
Copy link
Contributor

I will opt for creating the new issue and linking it to this one :)

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

No branches or pull requests

6 participants