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

fix(android): race condition on offBackgroundColor view change detection #9922

Merged

Conversation

NathanWalker
Copy link
Contributor

PR Checklist

What is the current behavior?

Various framework integrations, like Angular, may invoke view change detection cycles on property bindings at times when the nativeView is not available resulting in errors like:

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getTrackDrawable' of undefined
JS: TypeError: Cannot read property 'getTrackDrawable' of undefined
JS:     at Switch.setNativeBackgroundColor (file: src/webpack:/app/node_modules/@nativescript/core/ui/switch/index.android.js:48:0)
JS:     at Switch._onCheckedPropertyChanged (file: src/webpack:/app/node_modules/@nativescript/core/ui/switch/index.android.js:61:0)

What is the new behavior?

Switch is now resilient to this.

@cla-bot cla-bot bot added the cla: yes label May 24, 2022
@farfromrefug
Copy link
Collaborator

@NathanWalker shouldn't this be handle on the property side ? isn't it already? don't think we want this test everywhere. the property setter handler seems like a better place to me

@NathanWalker
Copy link
Contributor Author

@farfromrefug good question, it seems that because this function is reused several places, it's called outside the Property mechanics at times leading to the issue.

@NathanWalker NathanWalker merged commit 24c319e into alpha Jun 4, 2022
@NathanWalker NathanWalker deleted the fix/switch-race-condition-view-change-detection branch June 4, 2022 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants