Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2442)

Unified Diff: cc/resources/tile_manager.cc

Issue 366113002: cc: Do not cleanup tiles with raster tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit updated. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_manager.cc
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index dab3f5562823f5eadbdac2e7d7488726dee14f14..e01805b132deda41e7dabe066558110f230a24fe 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -389,23 +389,24 @@ TileManager::~TileManager() {
// our memory usage to drop to zero.
global_state_ = GlobalStateThatImpactsTilePriority();
- CleanUpReleasedTiles();
- DCHECK_EQ(0u, tiles_.size());
-
RasterTaskQueue empty;
rasterizer_->ScheduleTasks(&empty);
- orphan_raster_tasks_.clear();
// This should finish all pending tasks and release any uninitialized
// resources.
rasterizer_->Shutdown();
rasterizer_->CheckForCompletedTasks();
+ FreeResourcesForReleasedTiles();
+ CleanUpReleasedTiles();
+ DCHECK_EQ(0u, tiles_.size());
+
DCHECK_EQ(0u, bytes_releasable_);
DCHECK_EQ(0u, resources_releasable_);
}
void TileManager::Release(Tile* tile) {
+ DCHECK(TilePriority() == tile->combined_priority());
vmpstr 2014/07/21 15:24:14 Why does this work? I don't think we have code any
sohanjg 2014/07/22 14:17:46 Ideally, we should do SetPriority(TREE, TilePriori
vmpstr 2014/07/22 15:17:29 That's my question... I don't think it's the case
reveman 2014/07/22 16:21:21 Please give some example usage that justifies havi
vmpstr 2014/07/22 16:31:02 Suppose we have some tiles on the active tree with
reveman 2014/07/22 16:51:08 So I guess my next question is; does it make more
vmpstr 2014/07/22 17:23:34 I'm not sure I like the approach of clearing the p
reveman 2014/07/22 18:02:47 Yes, that would be the wrong reason to reset the p
sohanjg 2014/07/23 13:05:41 Done. Have reset the priority and removed the dche
prioritized_tiles_dirty_ = true;
released_tiles_.push_back(tile);
}
@@ -418,18 +419,27 @@ bool TileManager::ShouldForceTasksRequiredForActivationToComplete() const {
return global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY;
}
-void TileManager::CleanUpReleasedTiles() {
+void TileManager::FreeResourcesForReleasedTiles() {
for (std::vector<Tile*>::iterator it = released_tiles_.begin();
it != released_tiles_.end();
++it) {
Tile* tile = *it;
- ManagedTileState& mts = tile->managed_state();
+ FreeResourcesForTile(tile);
+ }
+}
- for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) {
- FreeResourceForTile(tile, static_cast<RasterMode>(mode));
- orphan_raster_tasks_.push_back(mts.tile_versions[mode].raster_task_);
+void TileManager::CleanUpReleasedTiles() {
+ DCHECK(prioritized_tiles_dirty_);
vmpstr 2014/07/21 15:24:14 This is kind of weird. Why are we requiring this t
sohanjg 2014/07/22 14:17:46 hmm..we had earlier seen some crashes when we clea
vmpstr 2014/07/22 15:17:29 Ah ok. This still makes it a bit fragile. The pr
reveman 2014/07/22 16:21:21 After, right? The idea with this DCHECK is that we
vmpstr 2014/07/22 16:31:02 Yeah, after. My only worry is that we set prioriti
reveman 2014/07/22 16:51:08 Yea, the DCHECK is not perfect. We could just move
sohanjg 2014/07/23 13:05:41 Done. Have kept the dcheck for now, and added a de
sohanjg 2014/07/23 14:16:32 Avoided the dcheck as it breaks tests, added todo
+ std::vector<Tile*>::iterator it = released_tiles_.begin();
+ while (it != released_tiles_.end()) {
+ Tile* tile = *it;
+
+ if (tile->HasRasterTask()) {
+ ++it;
+ continue;
}
+ DCHECK(!tile->HasResources());
DCHECK(tiles_.find(tile->id()) != tiles_.end());
tiles_.erase(tile->id());
@@ -442,15 +452,15 @@ void TileManager::CleanUpReleasedTiles() {
}
delete tile;
+ it = released_tiles_.erase(it);
}
-
- released_tiles_.clear();
}
void TileManager::UpdatePrioritizedTileSetIfNeeded() {
if (!prioritized_tiles_dirty_)
return;
+ FreeResourcesForReleasedTiles();
CleanUpReleasedTiles();
prioritized_tiles_.Clear();
@@ -484,6 +494,8 @@ void TileManager::DidFinishRunningTasks() {
return;
}
+ FreeResourcesForReleasedTiles();
+
resource_pool_->ReduceResourceUsage();
// We don't reserve memory for required-for-activation tiles during
@@ -973,11 +985,6 @@ void TileManager::ScheduleTasks(
// in |raster_tasks_|.
rasterizer_->ScheduleTasks(&raster_queue_);
- // It's now safe to clean up orphan tasks as raster worker pool is not
- // allowed to keep around unreferenced raster tasks after ScheduleTasks() has
- // been called.
- orphan_raster_tasks_.clear();
-
did_check_for_completed_tasks_since_last_schedule_tasks_ = false;
}
@@ -1071,18 +1078,12 @@ void TileManager::OnRasterTaskCompleted(
RasterMode raster_mode,
const PicturePileImpl::Analysis& analysis,
bool was_canceled) {
- TileMap::iterator it = tiles_.find(tile_id);
- if (it == tiles_.end()) {
- ++update_visible_tiles_stats_.canceled_count;
- resource_pool_->ReleaseResource(resource.Pass());
- return;
- }
+ DCHECK(tiles_.find(tile_id) != tiles_.end());
- Tile* tile = it->second;
+ Tile* tile = tiles_[tile_id];
ManagedTileState& mts = tile->managed_state();
ManagedTileState::TileVersion& tile_version = mts.tile_versions[raster_mode];
DCHECK(tile_version.raster_task_);
- orphan_raster_tasks_.push_back(tile_version.raster_task_);
tile_version.raster_task_ = NULL;
if (was_canceled) {
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698