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 placeholder #1555

Merged
merged 2 commits into from
Jun 28, 2019
Merged

Fix placeholder #1555

merged 2 commits into from
Jun 28, 2019

Conversation

strangeliu
Copy link
Contributor

Placeholder is not working anymore since placeholderEnabled is read from _flags but never set to it.

if (_flags.placeholderEnabled && !_placeholderImage && [self _locked_displaysAsynchronously]) {
- (BOOL)_locked_shouldHavePlaceholderLayer
{
  DISABLED_ASAssertLocked(__instanceLock__);
  return (_flags.placeholderEnabled && [self _implementsDisplay]);
}

@maicki maicki requested a review from bolsinga June 24, 2019 22:31
@maicki
Copy link
Contributor

maicki commented Jun 24, 2019

@bolsinga Hey Greg can you take a look please? Thanks!

@bolsinga
Copy link
Contributor

In #1484 (where the line quoted above changed) I see -setPlaceholderEnabled: which is setting the flag. In #1498 I'd removed those (due to the atomic / locking conundrum we'd discussed in Texture). This is the only one that had _flags in the removal, so I think it is the only that was broken.

@strangeliu Do you have a test that demonstrates this problem? If so it would be terrific to get a unit test that covers it so this doesn't break again.

@Adlai-Holler @maicki How should this one property be reconciled with the discussion in #1479?

@maicki
Copy link
Contributor

maicki commented Jun 28, 2019

Looking into ASControlNode it seems there are issues with the _flags.placeholderEnabled as @strangeliu correctly pointed out ...

  • The placeholderEnabled flag should should not exist if we use an atomic property for it. If we would use the atomic property, this mean that every time we are accessing or setting it internally we have to use the property directly and can not use the instance variable.
  • In the placeholderEnabled property case we have it here it's a bit more complicated though, as we are accessing it in code that is internally locked via the instance lock (calling _locked_shouldHavePlaceholderLayer within _locked_layoutPlaceholderIfNecessary). In this case we should in fact use an internal flag for placeholderEnabled and exposing setters and getters locked with the instance lock.

Therefore I think @strangeliu PR makes sense and we should go with it.

@strangeliu
Copy link
Contributor Author

@bolsinga I added a unit test for this.

Copy link
Contributor

@bolsinga bolsinga left a comment

Choose a reason for hiding this comment

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

Thanks for the test! And thanks for the advice @maicki

@bolsinga bolsinga merged commit 59ab0e8 into TextureGroup:master Jun 28, 2019
@maicki
Copy link
Contributor

maicki commented Jun 28, 2019

Glad it's resolved!

We may should add some documentation around the property implementations based on what I wrote above and adjust the places where we are not doing it. cc @bolsinga @nguyenhuy @mikezucc

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

Successfully merging this pull request may close these issues.

None yet

3 participants