-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Create Explicit Transation Avoid Implicit Checker #33225
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
cf4e169
to
8af2d25
Compare
8af2d25
to
82d87f7
Compare
cc @cyanglaz . I think this might be related to the platform views stuff you are working on right now. |
We begin transactions here: https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm#L287 and commit here: https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm#L561 These 2 locations are called for every frame that rasterizer runs on platform thread. Essentially, this change would make an additional CATransaction in 2 scenarios:
I'm not sure how either of the scenario fixed the issue mentioned in the PR. |
thanks for your reply, I've tried #33262 and is not fixed for me. From Apple
when the value layer.presentsWithTransaction changed, in some case, It will trigger layer tree modified and so Implicit transaction is created. and in flutter, it is on raster thread. If we set CA_ASSERT_MAIN_THREAD_TRANSACTIONS = 1 in add-to-app, It's not allowed to create Implicit transaction unless on main thread. This is why this code can fix my issue. |
I don't understand the full problem here, it looks like Do you know what causes the layer tree being modified? Is it because in Add-to-app, a non-flutter UIView is changed while the Flutter rasterizer is also running? |
In my case , It's a flutter app not Add-to-app. I mentioned Add-to-app just because I can set CA_ASSERT_MAIN_THREAD_TRANSACTIONS = 0 in flutter app to avoid this problem, but in Add-to-app I can't do that. From what I know flutter will set layer.presentsWithTransaction in ios_surface_metal.mm, and the value depend on current running thread. when platform thread and raster thread merged it will be YES, otherwise NO. It seems when the value changed from YES to NO will make layer tree modified. And implicit transaction is created, at this time it is on background thread (raster). |
It seems wrong that just by changing Maybe @chinmaygarde knows more about this. Though, I have been seeing some issue with threads unmerging. Sometimes, when threads are unmerging, a frame on the platform thread hasn't finished before a new frame is created on the raster thread, which hits some DChecks in the engine. It is only reproducible in local engine and flaky. It might be related. (I'm trying to find a more consistent way to reproduce it and document the issue) |
Maybe this issue is different with what you have met before. I have tried a native demo without flutter by create |
@cyanglaz I doing think I am the right person to review this. Are you able to reason about this? |
Sure! I can test it out. @houhuayong I remember we had some issue with CATransactions in the background thread: flutter/flutter#66647, we fixed it by only adding explicit CATransactions on the Platform Thread. #21526 I think the change in this PR will be a regression for flutter/flutter#66647. Can we find a different way to fix it? Or even better, maybe our diagnostic of flutter/flutter#66647 wasn't accurate and there is a way to avoid the crash while having explicit transactions on the background thread? |
From @cyanglaz s last comment it seems like we should not land this patch. Is that right? |
Correct. @houhuayong I think we should find a different way to support this. I'm going to close this PR. Please feel empowered to open a new PR if you know a different fix. |
fix: flutter/flutter#103390
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.