Changeset 202443 in webkit
- Timestamp:
- Jun 24, 2016 1:30:04 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202435 r202443 1 2016-06-24 Brian Burg <bburg@apple.com> 2 3 Web Inspector: CRASH in backend at Inspector::HeapFrontendDispatcher::garbageCollected + 552 when closing frontend/inspected page 4 https://bugs.webkit.org/show_bug.cgi?id=159075 5 <rdar://problem/26094341> 6 7 Reviewed by Joseph Pecoraro. 8 9 Move the asynchronous work to a task class that can be cancelled when the 10 heap agent is reset, disabled or destroyed. 11 12 * inspector/agents/InspectorHeapAgent.cpp: 13 (Inspector::SendGarbageCollectionEventsTask::SendGarbageCollectionEventsTask): 14 (Inspector::SendGarbageCollectionEventsTask::addGarbageCollection): 15 (Inspector::SendGarbageCollectionEventsTask::reset): 16 (Inspector::SendGarbageCollectionEventsTask::timerFired): 17 Added. This holds onto GarbageCollection objects that need to be sent asynchronously. 18 It uses the RunLoop variant of Timer and can queue multiple pending objects to be sent. 19 20 (Inspector::InspectorHeapAgent::InspectorHeapAgent): 21 (Inspector::InspectorHeapAgent::~InspectorHeapAgent): 22 (Inspector::InspectorHeapAgent::disable): 23 Reset the task when disabling or tearing down the agent so the timer doesn't fire after destruction. 24 25 (Inspector::InspectorHeapAgent::didGarbageCollect): 26 Send the object to the task to be dispatched asynchronously. 27 28 * inspector/agents/InspectorHeapAgent.h: 29 1 30 2016-06-24 Commit Queue <commit-queue@webkit.org> 2 31 -
trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp
r202383 r202443 40 40 namespace Inspector { 41 41 42 class SendGarbageCollectionEventsTask { 43 public: 44 SendGarbageCollectionEventsTask(HeapFrontendDispatcher&); 45 void addGarbageCollection(RefPtr<Inspector::Protocol::Heap::GarbageCollection>&&); 46 void reset(); 47 private: 48 void timerFired(); 49 50 HeapFrontendDispatcher& m_frontendDispatcher; 51 Vector<RefPtr<Inspector::Protocol::Heap::GarbageCollection>> m_garbageCollections; 52 RunLoop::Timer<SendGarbageCollectionEventsTask> m_timer; 53 }; 54 55 SendGarbageCollectionEventsTask::SendGarbageCollectionEventsTask(HeapFrontendDispatcher& frontendDispatcher) 56 : m_frontendDispatcher(frontendDispatcher) 57 , m_timer(RunLoop::current(), this, &SendGarbageCollectionEventsTask::timerFired) 58 { 59 } 60 61 void SendGarbageCollectionEventsTask::addGarbageCollection(RefPtr<Inspector::Protocol::Heap::GarbageCollection>&& garbageCollection) 62 { 63 m_garbageCollections.append(WTFMove(garbageCollection)); 64 65 if (!m_timer.isActive()) 66 m_timer.startOneShot(0); 67 } 68 69 void SendGarbageCollectionEventsTask::reset() 70 { 71 m_timer.stop(); 72 m_garbageCollections.clear(); 73 } 74 75 void SendGarbageCollectionEventsTask::timerFired() 76 { 77 // The timer is stopped on agent destruction, so this method will never be called after agent has been destroyed. 78 for (auto& event : m_garbageCollections) 79 m_frontendDispatcher.garbageCollected(event); 80 81 m_garbageCollections.clear(); 82 } 83 42 84 InspectorHeapAgent::InspectorHeapAgent(AgentContext& context) 43 85 : InspectorAgentBase(ASCIILiteral("Heap")) … … 46 88 , m_backendDispatcher(HeapBackendDispatcher::create(context.backendDispatcher, this)) 47 89 , m_environment(context.environment) 90 , m_sendGarbageCollectionEventsTask(std::make_unique<SendGarbageCollectionEventsTask>(*m_frontendDispatcher)) 48 91 { 49 92 } … … 51 94 InspectorHeapAgent::~InspectorHeapAgent() 52 95 { 96 m_sendGarbageCollectionEventsTask->reset(); 53 97 } 54 98 … … 82 126 83 127 m_environment.vm().heap.removeObserver(this); 128 m_sendGarbageCollectionEventsTask->reset(); 84 129 85 130 clearHeapSnapshots(); … … 277 322 // FIXME: Include number of bytes freed by collection. 278 323 279 double startTime = m_gcStartTime;280 double endTime = m_environment.executionStopwatch()->elapsedTime();281 282 324 // Dispatch the event asynchronously because this method may be 283 325 // called between collection and sweeping and we don't want to … … 287 329 // VM as the inspected page. 288 330 289 RunLoop::current().dispatch([this, startTime, endTime, operation]() { 290 auto collection = Inspector::Protocol::Heap::GarbageCollection::create() 291 .setType(protocolTypeForHeapOperation(operation)) 292 .setStartTime(startTime) 293 .setEndTime(endTime) 294 .release(); 295 296 m_frontendDispatcher->garbageCollected(WTFMove(collection)); 297 }); 331 m_sendGarbageCollectionEventsTask->addGarbageCollection(Inspector::Protocol::Heap::GarbageCollection::create() 332 .setType(protocolTypeForHeapOperation(operation)) 333 .setStartTime(m_gcStartTime) 334 .setEndTime(m_environment.executionStopwatch()->elapsedTime()) 335 .release()); 298 336 299 337 m_gcStartTime = NAN; -
trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h
r202383 r202443 38 38 39 39 class InjectedScriptManager; 40 class SendGarbageCollectionEventsTask; 40 41 typedef String ErrorString; 41 42 … … 74 75 InspectorEnvironment& m_environment; 75 76 77 std::unique_ptr<SendGarbageCollectionEventsTask> m_sendGarbageCollectionEventsTask; 78 76 79 bool m_enabled { false }; 77 80 bool m_tracking { false };
Note: See TracChangeset
for help on using the changeset viewer.