-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
CC @iskakaushik : just in case that you're interested in the shader warm-up work. Would you like to review this when it's out of wip? |
@liyuqian yes please! |
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.
Some initial suggestions.
@@ -210,4 +211,20 @@ bool WriteAtomically(const fml::UniqueFD& base_directory, | |||
base_directory.get(), file_name) == 0; | |||
} | |||
|
|||
std::vector<std::string> ListFiles(const fml::UniqueFD& directory) { | |||
std::vector<std::string> files; | |||
DIR* dir = ::fdopendir(directory.get()); |
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 being leaked without a balancing closedir
. I suggest creating a fml::UniqueObject<T>
. There is an early return as well. Its just easier with RAII wrappers.
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 cannot call closedir
because it will also close the corresponding UniqueFD
, and later reference to that UniqueFD
will fail. Also, we don't have to call closedir
because UniqueFD
will call close
on its destructor.
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.
::closedir
won't close the FD. The FD
and the DIR*
are different. Maybe that is why you had to rewinddir
?
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.
See #12412 (comment)
0458dac
to
2a2a398
Compare
2a2a398
to
fc39cfd
Compare
@chinmaygarde @iskakaushik : unit tests are added and the PR is now ready for review. |
fc39cfd
to
5ac4685
Compare
fml/file.h
Outdated
@@ -73,12 +78,37 @@ bool WriteAtomically(const fml::UniqueFD& base_directory, | |||
const char* file_name, | |||
const Mapping& mapping); | |||
|
|||
using FileVisitor = std::function<void(const fml::UniqueFD& directory, |
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.
Can we make the FileVisitor
return a bool
to indicate if further traversal is necessary? For example, folks can use this to implement a FindFile
whereby they can return false
when a file is found so further traversal is unnecessary.
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.
Please document if the filename is relative or absolute.
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.
filename
inherently implies it's the name of the file as opposed to filepath, 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.
Sure, it now returns bool
. I agree that filename
sounds clear to me but it's no harm to add a comment to make it even clearer.
fml/file.h
Outdated
/// use our helper method `VisitFilesRecursively`. | ||
/// | ||
/// @see `VisitFilesRecursively`. | ||
void VisitFiles(const fml::UniqueFD& directory, const FileVisitor& visitor); |
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.
You don't need to pass closures by const reference. Just FileVisitor visitor
is fine.
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.
@@ -210,4 +211,20 @@ bool WriteAtomically(const fml::UniqueFD& base_directory, | |||
base_directory.get(), file_name) == 0; | |||
} | |||
|
|||
std::vector<std::string> ListFiles(const fml::UniqueFD& directory) { | |||
std::vector<std::string> files; | |||
DIR* dir = ::fdopendir(directory.get()); |
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.
::closedir
won't close the FD. The FD
and the DIR*
are different. Maybe that is why you had to rewinddir
?
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.
Sorry, I accidentally approved earlier. Can you make sure to recheck how you got away with not requiring a ::closedir
?
Calling
BTW, I've also reset your accidental approval :) |
Try to dismiss the accidental approval
@@ -58,4 +59,23 @@ ScopedTemporaryDirectory::~ScopedTemporaryDirectory() { | |||
} | |||
} | |||
|
|||
void VisitFilesRecursively(const fml::UniqueFD& directory, | |||
const FileVisitor& visitor) { | |||
FileVisitor recursive_visitor = [&recursive_visitor, &visitor]( |
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.
nit: you could use nftw https://linux.die.net/man/3/nftw to simplify this.
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.
Ah, nftw
looks useful. Do you also happen to know the corresponding API for Windows? I wonder if I shall adjust our API to be more close to ntfw
(e.g., provide nopenfd
argument)
static void SetCacheSkSL(bool value); | ||
static void MarkStrategySet() { strategy_set_ = true; } | ||
|
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 wonder if we can use some builder like pattern here. Like:
PersistentCacheBuilder
.setCacheSkSl(true)
...
.build()
That way we could avoid having this extra flag. But i'm not sure if this is a common c++ paradigm.
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 use this pattern in the embedder_unittests
in for the EmbedderConfigBuilder
.
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 like the builder pattern, but it doesn't seem to be compatible with our current PersistentCache::GetCacheForProcess
usages. If we think that it's worth to do a yak shave to remove PersistentCache::GetCacheForProcess
and let Shell
own the PersistentCache
used by Rasterizer
and IOManager
, maybe we shall do that in another isolated PR and create an issue to track its progress.
bcad574
to
2c41d1d
Compare
Otherwise, the unit test would fail if previous unit tests have already set the PersistentCache with different settings.
I've finally made all tests pass on both Windows and Linux 😄 This is now ready for review again @chinmaygarde @iskakaushik |
git@github.com:flutter/engine.git/compare/5b3182294f63...c635d70 git log 5b31822..c635d70 --no-merges --oneline 2019-10-08 skia-flutter-autoroll@skia.org Roll src/third_party/skia 902cf1e12a74..1494a7f1ec03 (10 commits) (flutter/engine#13000) 2019-10-08 liyuqian@google.com SkSL precompile (flutter/engine#12412) 2019-10-08 chinmaygarde@google.com Compile sanitizer suppressions list and file bugs as necessary. (flutter/engine#12991) 2019-10-08 chinmaygarde@google.com Add a unit-test to verify that root surface transformation affect platform view coordinates. (flutter/engine#12783) 2019-10-08 katelovett@google.com Re-land Adding Link Semantics (flutter/engine#12972) 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 chinmaygarde@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
So we can test SkSL precompile using the command line tools. See flutter/engine#12412.
So we can test SkSL precompile using the command line tools. See flutter/engine#12412.
git@github.com:flutter/engine.git/compare/5b3182294f63...c635d70 git log 5b31822..c635d70 --no-merges --oneline 2019-10-08 skia-flutter-autoroll@skia.org Roll src/third_party/skia 902cf1e12a74..1494a7f1ec03 (10 commits) (flutter/engine#13000) 2019-10-08 liyuqian@google.com SkSL precompile (flutter/engine#12412) 2019-10-08 chinmaygarde@google.com Compile sanitizer suppressions list and file bugs as necessary. (flutter/engine#12991) 2019-10-08 chinmaygarde@google.com Add a unit-test to verify that root surface transformation affect platform view coordinates. (flutter/engine#12783) 2019-10-08 katelovett@google.com Re-land Adding Link Semantics (flutter/engine#12972) 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 chinmaygarde@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
So we can test SkSL precompile using the command line tools. See flutter/engine#12412.
For flutter/flutter#40686
Unit tests added: