-
Notifications
You must be signed in to change notification settings - Fork 6k
Fixing bug when ListenableEditingState
is provided initialState
with a valid composing range, android.view.inputmethod.BaseInputConnection.setComposingRegion(int, int)
has NPE
#30916
Conversation
This pull request was opened against a branch other than main. Since Flutter pull requests should not normally be opened against branches other than main, I have changed the base to main. If this was intended, you may modify the base back to master. See the Release Process for information about how other branches get updated. Reviewers: Use caution before merging pull requests to branches other than main, unless this is an intentional hotfix/cherrypick. |
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
1 similar comment
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Well cannot understand that CI error... Have searched keyword Possibly related @chinmaygarde @darshankawar |
The "Linux Unopt" CI error is asking for a change to the code formatting The "build_and_test_linux_unopt_debug" CI error is a flaky test that has been seen before (see flutter/flutter#95751) |
@jason-simmons thanks! done |
@@ -141,7 +141,11 @@ public void setComposingRange(int composingStart, int composingEnd) { | |||
if (composingStart < 0 || composingStart >= composingEnd) { | |||
BaseInputConnection.removeComposingSpans(this); | |||
} else { | |||
mDummyConnection.setComposingRegion(composingStart, composingEnd); | |||
if (mDummyConnection != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make more sense to move the mDummyConnection
initialization to before the setEditingState
call in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. Notice mDummyConnection is init as:
Editable self = this;
mDummyConnection =
new BaseInputConnection(view, true) {
@Override
public Editable getEditable() {
return self;
}
};
Where there is a self
(indeed this
). If we move it at the beginning of constructor, that getEditable
can return a not-fully-initialized instance imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly the dummy connection is a quirk to get access to the BaseInputConnection.setComposingRegion
static method:
https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/inputmethod/BaseInputConnection.java;l=104-128;drc=master?q=BaseInputConnection
Since it's called after the super implementation, and all the dummy connection does is changing the current composing region, it should be fine to return the Editable
I think (feel free to add a code comment there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for fixing this!
You are welcome! |
…State` with a valid composing range, `android.view.inputmethod.BaseInputConnection.setComposingRegion(int, int)` has NPE (flutter/engine#30916)
@chinmaygarde is there an HF version? |
In flutter version "2.10.0-stable" the bug seems not resolved, I've tested with my app. |
Would be great if this could be merged into stable! This is our most occurring issue at the moment |
Given my understanding of flutter, seems that we need to wait until next stable (which is roughly 2 months later, unfortunately) if it is not in 2.10. Or, we may make a cherry-pick request |
Still get the error with:
Specifically when I double-tap to select the text in a text field. |
Looks like this fix has not been included in stable channel yet. Does anybody know where it was included? |
@gonzalonm May I know where you see it not in stable? from the release date it should have been stable |
I didn't see it in the release notes. Anyways, I could not reproduce the issue with version |
It may be in release notes of engine, while flutter/flutter repo (not flutter/engine) will not say this |
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
See flutter/flutter#96570
List which issues are fixed by this PR. You must list at least one issue.
Fix flutter/flutter#96570
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.