Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[ASNetworkImageNode] Whenever URL is set, prefer it over a manually-set .image.#2774

Merged
appleguy merged 1 commit intofacebookarchive:masterfrom
garrettmoon:dontBehaveLikeAnImageNodeIfURLSet
Dec 15, 2016
Merged

[ASNetworkImageNode] Whenever URL is set, prefer it over a manually-set .image.#2774
appleguy merged 1 commit intofacebookarchive:masterfrom
garrettmoon:dontBehaveLikeAnImageNodeIfURLSet

Conversation

@garrettmoon
Copy link
Copy Markdown
Contributor

After much discussion I think this is the correct behavior. It seems
like it's much more likely to be the expected behavior but still enables
you to use the network image node like an regular image node.

Resolves #2756

After much discussion I think this is the correct behavior. It seems
like it's much more likely to be the expected behavior but still enables
you to use the network image node like an regular image node.
@garrettmoon
Copy link
Copy Markdown
Contributor Author

@maicki @appleguy @Adlai-Holler would appreciate your eyes on this :)

Copy link
Copy Markdown
Contributor

@maicki maicki left a comment

Choose a reason for hiding this comment

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

After thinking about it I think we should take a step back and let ASNetworkImageNode not let to set any image directly at all. We should assert in this case and in the assertion message we should point to the defaultImage. In production if someone set's the image directly we would just call through to the default image.

[self _cancelDownloadAndClearImage];
_URL = nil;
}
_imageWasSetExternally = (image != nil && _URL != nil);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this change would make the ASNetworkImage back to the old unpredictables behavior. The behavior of the network image node would be based on the order of setting the properties. The behavior would depend on setting the URL before or after setting the image. Without this change it behaved like either an image node or a network image node, now it's kind of a hybrid thing ...

Copy link
Copy Markdown
Contributor

@appleguy appleguy Dec 15, 2016

Choose a reason for hiding this comment

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

@maicki I don't think that's quite right, due to the code in setURL, which prevents the problem.

The problem case would seem to be when you do setImage:, and then later do setURL:, this code will do _imageWasSetExternally = YES; however, that's not the case because setURL: will clear the flag.

@garrettmoon garrettmoon changed the title Don't behave like an image node if URL is set. [ASNetworkImageNode] Don't behave like an image node if URL is set. Dec 15, 2016
Copy link
Copy Markdown
Contributor

@appleguy appleguy left a comment

Choose a reason for hiding this comment

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

We may need to change this code further, but I'm going to land this now for a simple reason: the current state in master is not correct, and causes Pinterest to NEVER (100%) load the correct-resolution image.

In other words, today, this NEVER works:
.image = lowerResolutionStarterImage;
.url = URLForActualFullResImage;

In this case, or with the opposite call order, we will never load the image!

That said, we should all agree -- the behavior we land on MUST be the same regardless of the order you set .image and .URL. I believe that is the case now after this patch, but if it isn't, we'll change it again until it is consistent.

By landing this, we'll at least get a Pinterest build to confirm the behavior is improved and from there we can write a unit test to run through all 4 permutations of setting these two properties.

[self _cancelDownloadAndClearImage];
_URL = nil;
}
_imageWasSetExternally = (image != nil && _URL != nil);
Copy link
Copy Markdown
Contributor

@appleguy appleguy Dec 15, 2016

Choose a reason for hiding this comment

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

@maicki I don't think that's quite right, due to the code in setURL, which prevents the problem.

The problem case would seem to be when you do setImage:, and then later do setURL:, this code will do _imageWasSetExternally = YES; however, that's not the case because setURL: will clear the flag.

@appleguy appleguy merged commit dabb69d into facebookarchive:master Dec 15, 2016
@appleguy appleguy changed the title [ASNetworkImageNode] Don't behave like an image node if URL is set. [ASNetworkImageNode] Whenever URL is set, prefer it over a manually-set .image. Dec 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants