diff --git a/CHANGELOG.md b/CHANGELOG.md index ce58586f6..9d28b712a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,4 +24,4 @@ - [Layout] Extract layout implementation code into it's own subcategories [Michael Schneider] (https://github.com/maicki)[#272](https://github.com/TextureGroup/Texture/pull/272) - [Fix] Fix a potential crash when cell nodes that need layout are deleted during the same runloop. [Adlai Holler](https://github.com/Adlai-Holler) [#279](https://github.com/TextureGroup/Texture/pull/279) - [Batch fetching] Add ASBatchFetchingDelegate that takes scroll velocity and remaining time into account [Huy Nguyen](https://github.com/nguyenhuy) [#281](https://github.com/TextureGroup/Texture/pull/281) - +- [Fix] Fix a major regression in our image node contents caching. [Adlai Holler](https://github.com/Adlai-Holler) [#287](https://github.com/TextureGroup/Texture/pull/287) diff --git a/Source/ASImageNode.mm b/Source/ASImageNode.mm index 94e1440fb..d36509d56 100644 --- a/Source/ASImageNode.mm +++ b/Source/ASImageNode.mm @@ -113,15 +113,18 @@ - (BOOL)isEqual:(id)object - (NSUInteger)hash { +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wpadded" struct { NSUInteger imageHash; CGSize backingSize; CGRect imageDrawRect; - BOOL isOpaque; + NSInteger isOpaque; NSUInteger backgroundColorHash; void *willDisplayNodeContentWithRenderingContext; void *didDisplayNodeContentWithRenderingContext; void *imageModificationBlock; +#pragma clang diagnostic pop } data = { _image.hash, _backingSize, diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index d1334b21b..5102ad6a0 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -64,9 +64,12 @@ @implementation ASTextNodeRendererKey - (NSUInteger)hash { +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wpadded" struct { size_t attributesHash; CGSize constrainedSize; +#pragma clang diagnostic pop } data = { _attributes.hash(), _constrainedSize diff --git a/Source/Private/ASHashing.h b/Source/Private/ASHashing.h index c658a42d3..0fc8d72ff 100644 --- a/Source/Private/ASHashing.h +++ b/Source/Private/ASHashing.h @@ -34,6 +34,11 @@ ASDISPLAYNODE_EXTERN_C_BEGIN * _bounds.size * }; * return ASHashBytes(&data, sizeof(data)); + * + * @warning: If a struct has padding, any fields that are intiailized in {} + * will have garbage data for their padding, which will break this hash! Either + * use `pragma clang diagnostic warning "-Wpadded"` around your struct definition + * or manually initialize the fields of your struct (`myStruct.x = 7;` etc). */ NSUInteger ASHashBytes(void *bytes, size_t length); diff --git a/Source/TextKit/ASTextKitAttributes.mm b/Source/TextKit/ASTextKitAttributes.mm index 3e6dc8082..abe55c81d 100755 --- a/Source/TextKit/ASTextKitAttributes.mm +++ b/Source/TextKit/ASTextKitAttributes.mm @@ -24,6 +24,8 @@ size_t ASTextKitAttributes::hash() const { +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wpadded" struct { NSUInteger attrStringHash; NSUInteger truncationStringHash; @@ -35,6 +37,7 @@ NSUInteger shadowColorHash; CGFloat shadowOpacity; CGFloat shadowRadius; +#pragma clang diagnostic pop } data = { [attributedString hash], [truncationAttributedString hash],