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

DTAttributedTextContentView will cause Zombie layer object crash when Using DTTiledLayerWithoutFade #1250

Open
ximmyxiao opened this issue Apr 2, 2022 · 11 comments

Comments

@ximmyxiao
Copy link
Contributor

ximmyxiao commented Apr 2, 2022

@odrobnik Can you do me a favour to look at this problem? This crash bothered my project for years , and I don't know how to fix it

the problem seems like when DTAttributedTextContentView 's layer is using DTTiledLayerWithoutFade, any subview added to DTAttributedTextContentView will be deallocated unexpected when the whole tableview deallocating . and this will cause some crash.
image

I reproduce the crash with the official example of DTCoreText, You guys can see the commit here:
https://github.com/ximmyxiao/DTCoreText/commit/cbad674d10ff33fd5cce7c9d6ca5e19602a58f93

@ximmyxiao
Copy link
Contributor Author

ximmyxiao commented Apr 2, 2022

seems DTAttributedTextContentView emebed in TableViewCell is also a key point to crash

@ximmyxiao
Copy link
Contributor Author

ximmyxiao commented Apr 2, 2022

And I found this problem only exist in TableviewCells(or the view directly added as UITableView's subview) who got a DTAttributedTextContentView as its subview , and if this DTAttributedTextContentView has any subview , this subview's layer will be deallocated before the subview deallocated . so this makes the zombie happen

@odrobnik
Copy link
Collaborator

odrobnik commented Apr 2, 2022

I guess you shouldn't use tiling inside table view cells!

@ximmyxiao
Copy link
Contributor Author

ximmyxiao commented Apr 4, 2022

@odrobnik But in DTAttributedTextContentView's layoutSubviews , there will be a warning about this

	if (!_isTiling && (self.bounds.size.width>1024.0 || self.bounds.size.height>1024.0))
	{
		if (![self.layer isKindOfClass:[CATiledLayer class]])
		{
			NSLog(@"Warning: A %@ with size %@ is using a non-tiled layer. Set the layer class to a CATiledLayer subclass with [DTAttributedTextContentView setLayerClass:[DTTiledLayerWithoutFade class]].", NSStringFromClass([self class]), NSStringFromCGSize(self.bounds.size));
		}
	}

And In my project the DTAttributedTextContentView 's size may bigger that 1024 often.
may be this warning should be suggest that , if you are using DTAttributedTextContentView in a tableview cell , this warning can be omited?

@odrobnik
Copy link
Collaborator

odrobnik commented Apr 4, 2022

That's from a long time ago. If you find that non-tiling works with greater view sizes, then you can increase the size and send a PR.

@ximmyxiao
Copy link
Contributor Author

ximmyxiao commented Apr 4, 2022

OK, I 'll test non-tiling mode in my project for a while , In fact , the HTML to be rendered in my project may contains many pictures( 100 + pictures,each of them got a file size bigger then 500K) , If it turns out that non-tiling works well for even this extreme situation , I will let you know and send a PR . . Thanks @odrobnik

@odrobnik
Copy link
Collaborator

@ximmyxiao what was the PR you wanted to suggest? Just to take out the warning?

@ximmyxiao
Copy link
Contributor Author

ximmyxiao commented May 16, 2022

@odrobnik YES,in my project I just omit this warning , maybe a variable indicated that this DTAttributedTextContentView is contained in the UITableView or not , and the warning will be generated on this variable . Both of these method seems not so beautiful maybe , What do you think is the best way to fix this

@odrobnik
Copy link
Collaborator

@ximmyxiao well, we can probably simple remove the warning. Or possibly put in a check if the view has a tableview in its super path to warn about tiling instead. i.e. inside a tableview cell, we warn if there is tiling, otherwise we warn if the view is large and there is no tiling.

@ximmyxiao
Copy link
Contributor Author

@odrobnik OK, I have just just published my app with this change(omit the warning) , I 'll let you know if this change is good or not after one or two weeks

@ximmyxiao
Copy link
Contributor Author

@odrobnik After watching my app in 2 weeks ,everything go well after 1 remove the using of DTTiledLayerWithoutFade 2 omit the warning . I think the new version of DTCoreText can do something similar change

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

No branches or pull requests

2 participants