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

[TextFields] Add identity check in -setTextColor: in MDCTextField #9480

Merged
merged 2 commits into from Jan 24, 2020

Conversation

andrewoverton
Copy link
Contributor

@andrewoverton andrewoverton commented Jan 23, 2020

This PR adds an identity check in -setTextColor: in MDCTextField. This identity check short circuits an infinite loop triggered by -setTextColor: under certain mysterious circumstances involving the MDCTextField layout pass and MDCFlexibleHeaderView KVO stuff surrounding safeAreaInset changes. I don't fully understand what's going on tbh :)

The internal bug (b/148159587) has links to before and after gifs in the comments.

Closes #9470

Update: The internal client who reported the bug was unable to reproduce it with these changes.

@bryanoltman
Copy link
Contributor

How did you verify that this fixes the issue?

@andrewoverton
Copy link
Contributor Author

I built the app and added a bunch of breakpoints and eventually zeroed in on which method calls were necessary to trigger the infinite loop and then found a way to make it so they weren't made again and again and again. It's bizarre. There's some interplay between the layout process of the text field and some "safeAreaInsetsDidChange" logic in flexible header that is just no good!

@andrewoverton
Copy link
Contributor Author

Oh and I updated the PR description to link to the bug which links to some before and after gifs

@material-automation
Copy link

material-automation commented Jan 23, 2020

bazel detected changes to the following targets:

//components/Chips:snapshot_tests
//components/Chips:snapshot_tests_test_bundle
//components/Chips:unit_tests
//components/Chips:unit_tests_IPAD_PRO_12_9_IN_9_3
//components/Chips:unit_tests_IPAD_PRO_12_9_IN_9_3_test_bundle
//components/Chips:unit_tests_IPHONE_7_PLUS_IN_10_3
//components/Chips:unit_tests_IPHONE_7_PLUS_IN_10_3_test_bundle
//components/Chips:unit_tests_environment
//components/Chips:unit_tests_environment_test_bundle
//components/TextFields:snapshot_tests
//components/TextFields:snapshot_tests_test_bundle
//components/TextFields:unit_tests
//components/TextFields:unit_tests_IPAD_PRO_12_9_IN_9_3
//components/TextFields:unit_tests_IPAD_PRO_12_9_IN_9_3_test_bundle
//components/TextFields:unit_tests_IPHONE_7_PLUS_IN_10_3
//components/TextFields:unit_tests_IPHONE_7_PLUS_IN_10_3_test_bundle
//components/TextFields:unit_tests_IPHONE_X_IN_11_0
//components/TextFields:unit_tests_IPHONE_X_IN_11_0_test_bundle

Copy link
Contributor

@bryanoltman bryanoltman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe add a comment above the textColor != self.textColor check mentioning why you added it, just in case someone thinks it's an unnecessary optimization somewhere down the line.

@andrewoverton
Copy link
Contributor Author

Good idea, I'll do that

@andrewoverton andrewoverton merged commit 7a48d39 into material-components:develop Jan 24, 2020
@andrewoverton andrewoverton deleted the issue-9470 branch January 24, 2020 17:58
andrewoverton added a commit that referenced this pull request Jan 24, 2020
)

This PR adds an identity check in `-setTextColor:` in MDCTextField. This identity check short circuits an infinite loop triggered by `-setTextColor:` under certain mysterious circumstances involving the MDCTextField layout pass and MDCFlexibleHeaderView KVO stuff surrounding safeAreaInset changes. I don't fully understand what's going on tbh :)

The internal bug ([b/148159587](http://b/148159587)) has links to before and after gifs in the comments.

Closes #9470

### Update: The internal client who reported the bug was unable to reproduce it with these changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants