[Google3 Bug]: ProcessTextPlugin.queryTextActions causing ANRs
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Help us understand the severity of this issue
- [ ] causing severe production issues e.g. malfunctions or data loss
- [ ] blocking next binary release
- [ ] blocking a client feature launch within a quarter
- [x] nice-to-have but does not block a launch within the next quarter
### Steps to reproduce
When editable text widget is rendered or user long taps text in editable text widget, ProcessTextPlugin.queryTextActions is called that triggers ResolveInfo.loadLabel binder method that blocks the main thread for more than 5s, causing ANR.
Stack trace:
```
#00 pc 0x000000000003b0dc /system/lib/libandroidfw.so (android::ChunkIterator::Next+100)
#01 pc 0x000000000003ed1f /system/lib/libandroidfw.so (android::LoadedPackage::Load+598)
#02 pc 0x0000000000040b1d /system/lib/libandroidfw.so (android::LoadedArsc::LoadTable+308)
#03 pc 0x0000000000040f01 /system/lib/libandroidfw.so (android::LoadedArsc::Load+164)
#04 pc 0x0000000000029365 /system/lib/libandroidfw.so (android::ApkAssets::LoadImpl+252)
#05 pc 0x00000000000290ab /system/lib/libandroidfw.so (android::ApkAssets::LoadImpl+190)
#06 pc 0x0000000000028e4b /system/lib/libandroidfw.so (android::ApkAssets::Load+34)
#07 pc 0x000000000012f1e3 /system/lib/libandroid_runtime.so (android::NativeLoad+882)
at android.content.res.ApkAssets.nativeLoad (Native method)
at android.content.res.ApkAssets. (ApkAssets.java:296)
at android.content.res.ApkAssets.loadFromPath (ApkAssets.java:145)
at android.app.ResourcesManager.loadApkAssets (ResourcesManager.java:472)
at android.app.ResourcesManager.-$$Nest$mloadApkAssets (unavailable)
at android.app.ResourcesManager$ApkAssetsSupplier.load (ResourcesManager.java:167)
at android.app.ResourcesManager.createApkAssetsSupplierNotLocked (ResourcesManager.java:997)
at android.app.ResourcesManager.getResources (ResourcesManager.java:1118)
at android.app.ActivityThread.getTopLevelResources (ActivityThread.java:2506)
at android.app.ApplicationPackageManager.getResourcesForApplication (ApplicationPackageManager.java:2037)
at android.app.ApplicationPackageManager.getResourcesForApplication (ApplicationPackageManager.java:2023)
at android.app.ApplicationPackageManager.getText (ApplicationPackageManager.java:2349)
at android.content.pm.ComponentInfo.loadUnsafeLabel (ComponentInfo.java:130)
at android.content.pm.PackageItemInfo.loadLabel (PackageItemInfo.java:212)
at android.content.pm.ResolveInfo.loadLabel (ResolveInfo.java:238)
at io.flutter.plugin.text.ProcessTextPlugin.queryTextActions (ProcessTextPlugin.java:57)
at io.flutter.embedding.engine.systemchannels.ProcessTextChannel$1.onMethodCall (ProcessTextChannel.java:63)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage (MethodChannel.java:267)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler (DartMessenger.java:286)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0 (DartMessenger.java:313)
at io.flutter.embedding.engine.dart.DartMessenger.$r8$lambda$xiVpfGssfwbeQV0MS1TxLCE19hA (DartMessenger.java:1)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run (D8$$SyntheticClass:13)
at android.os.Handler.handleCallback (Handler.java:942)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:201)
at android.os.Looper.loop (Looper.java:288)
at android.app.ActivityThread.main (ActivityThread.java:7941)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:569)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1015)
```
Related past issues: https://github.com/flutter/flutter/issues?q=queryTextActions%20anr
Please see b/532829373 for the proposed fix.
### Expected results
Editable text widget renders without incident or available text actions are shown when user long taps text in editable text widget.
### Actual results
ANR occurs.
### Code sample
Code sample
```dart
[Paste your code here]
```
### Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
### Logs
Logs
```console
[Paste your logs here]
```
### Flutter Doctor output
Doctor output
```console
[Paste your output here]
```
Contributor guide
Research direction
Start at ProcessTextPlugin.java:57 and trace queryTextActions through the Android text-action flow, focusing on the ResolveInfo.loadLabel call shown in the stack trace. Review the proposed fix in b/532829373, then reproduce with an editable text widget and a long tap. Done means the widget renders and text actions can be queried without an ANR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100