diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f88d834..c58a9bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,3 +12,4 @@ - Move more properties from ASTableView, ASCollectionView to their respective node classes. [Adlai Holler](https://github.com/Adlai-Holler) - Remove finalLayoutElement [Michael Schneider] (https://github.com/maicki)[#96](https://github.com/TextureGroup/Texture/pull/96) - Add ASPageTable - A map table for fast retrieval of objects within a certain page [Huy Nguyen](https://github.com/nguyenhuy) +- [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 e933461a..3ceea57d 100644 --- a/Source/ASImageNode.mm +++ b/Source/ASImageNode.mm @@ -102,15 +102,18 @@ struct ASImageNodeDrawParameters { - (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 251ab237..a99d1183 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -68,9 +68,12 @@ struct ASTextNodeDrawParameter { - (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 c658a42d..0fc8d72f 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 3e6dc808..abe55c81 100755 --- a/Source/TextKit/ASTextKitAttributes.mm +++ b/Source/TextKit/ASTextKitAttributes.mm @@ -24,6 +24,8 @@ NSString *const ASTextKitEntityAttributeName = @"ck_entity"; size_t ASTextKitAttributes::hash() const { +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wpadded" struct { NSUInteger attrStringHash; NSUInteger truncationStringHash; @@ -35,6 +37,7 @@ size_t ASTextKitAttributes::hash() const NSUInteger shadowColorHash; CGFloat shadowOpacity; CGFloat shadowRadius; +#pragma clang diagnostic pop } data = { [attributedString hash], [truncationAttributedString hash],