-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Impeller] switch Pipeline to use raw ptr instead of shared ptr for recorded references. #57015
Conversation
@@ -377,338 +377,338 @@ class ContentContext { | |||
|
|||
Tessellator& GetTessellator() const; | |||
|
|||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline( | |||
const Pipeline<PipelineDescriptor>* GetFastGradientPipeline( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of wrapping this up in a raw_ptr class. That way in debug builds we could actually assert we aren't using dangling pointers.
template<typename T>
class raw_ptr {
public:
raw_ptr(const std::shared_ptr<T>& ptr)
: ptr_(ptr.get())
#if !NDEBUG
, weak_ptr_(ptr)
#endif
{}
T* get() {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return ptr_;
}
private:
T* ptr_;
#if !NDEBUG
std::weak_ptr<T> weak_ptr_;
#endif
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will never use the class as I never run unopt builds. I don't think we should add infrastructure for the one or two people who do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is executed by CI though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so are things like ASAN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than writing our own ASAN code, can we just use ASAN on our tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to. There is some weirdness when executing on linux. You have to make a fake X instance. Looks like we have something in run_tests.py that does this already: https://github.com/gaaclarke/engine/blob/9fff75d9364fb3eafb62240ac1ab04f76ef914cd/testing/run_tests.py#L1220
You have to specify "impeller" as the variant though (we are just specifying engine). I don't know if it works. It might not if there are no builders executing it. I think this goes back all the way to when kaushik hooked up it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can try adding "impeller" to the variant in linux_unopt.json and see if it works 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried just throwing in impeller
with the asan target, it didn't work: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8729261574606027697/+/u/test:_test:_Host_Tests_for_host_debug_unopt/stdout
The virtual display doesn't seem to be working. This is the same sort of issues I ran into when trying to get golden tests running on linux. We should have ASAN as an option on macos. That may be the easier approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get things compiling with ASAN on macos:
$ ./flutter/tools/gn --unoptimized --runtime-mode=debug --no-rbe --no-goma --asan --mac-cpu=arm64
$ ninja -j8 -C out/host_debug_unopt_arm64 impeller_golden_tests
[5/2329] ACTION //flutter/impeller/runtime_stage:flatc_runtime_stage_flatbuffers(//build/toolchain/mac:clang_arm64)
FAILED: gen/flutter/impeller/runtime_stage/runtime_stage_flatbuffers.h
vpython3 ../../build/gn_run_binary.py flatc --warnings-as-errors --cpp --cpp-std c++17 --cpp-static-reflection --gen-object-api --filename-suffix _flatbuffers -o gen/flutter/impeller/runtime_stage ../../flutter/impeller/runtime_stage/runtime_stage.fbs
Command failed: ./flatc --warnings-as-errors --cpp --cpp-std c++17 --cpp-static-reflection --gen-object-api --filename-suffix _flatbuffers -o gen/flutter/impeller/runtime_stage ../../flutter/impeller/runtime_stage/runtime_stage.fbs
exitCode: -6
dyld[61885]: missing symbol called
edit: looks like ASAN wants a runtime library and it's creating a weird link in the macho file
$ otool -L flatc
flatc:
@rpath/libclang_rt.asan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed an issue for ASAN: flutter/flutter#159985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea going this way sounds easier for now. I'd still like to get ASAN working at some point. I'll file an issue. LGTM modulo a place where I think there is a typo.
const Pipeline<PipelineDescriptor>* GetPipeline( | ||
Variants<TypedPipeline>& container, | ||
ContentContextOptions opts) const { | ||
PipelineRef GetPipeline(Variants<TypedPipeline>& container, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a comment somewhere that says why we are able to pass around raw_ptrs. This is the best place I can think of. Or maybe at the typedef?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, on the typedef.
impeller/entity/entity_unittests.cc
Outdated
@@ -1696,7 +1697,7 @@ TEST_P(EntityTest, RuntimeEffect) { | |||
ASSERT_TRUE(runtime_stage->IsDirty()); | |||
|
|||
bool expect_dirty = true; | |||
const Pipeline<PipelineDescriptor>* first_pipeline; | |||
const raw_ptr<Pipeline<PipelineDescriptor>*> first_pipeline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right, you have a pointer to a pointer here. It should be raw_ptr<PipelineDescriptor>>
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an outdated diff...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks! I'll continue to poke around at asan.
auto label is removed for flutter/engine/57015, due to - The status or check suite Linux linux_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Remove FML_CHECK on == so we can make comparison to nullptr.
… ptr for recorded references. (flutter/engine#57015)
…160000) flutter/engine@37a7a14...4d0e9ac 2024-12-09 [email protected] [Impeller] switch Pipeline to use raw ptr instead of shared ptr for recorded references. (flutter/engine#57015) 2024-12-09 [email protected] [Impeller] disable all Adrenos older than 630 (flutter/engine#57069) 2024-12-09 [email protected] Roll Skia to 14f8f6d984ff (flutter/engine#57068) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…tr for recorded references." (#57079) Reverts #57015 fixes flutter/flutter#160004
…ecorded references. (flutter/engine#57015) Fixes flutter#159566 We don't need recorded commands to keep pipelines alive as the context does that already.
…tr for recorded references." (flutter/engine#57079) Reverts flutter/engine#57015 fixes flutter#160004
…tr for recorded references. (flutter/engine#57086) Prev: flutter/engine#57015 There is a unit test that is clearing out the pipeline storage, manually null out captured PipelineRef.
Fixes flutter/flutter#159566
We don't need recorded commands to keep pipelines alive as the context does that already.