diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index f5b1f543d769..d61f94ec1fc8 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -1099,10 +1099,14 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget, if (aPresContext && aPresContext->GetRootPresContext()) { nsRefreshDriver* driver = aPresContext->GetRootPresContext()->RefreshDriver(); - if (driver && driver->HasPendingTick()) { - driver->RegisterCompositionPayload( - {layers::CompositionPayloadType::eKeyPress, - aEvent->mTimeStamp}); + if (driver && driver->ViewManagerFlushIsPending()) { + nsIWidget* widget = aPresContext->GetRootWidget(); + layers::LayerManager* lm = + widget ? widget->GetLayerManager() : nullptr; + if (lm) { + lm->RegisterPayload({layers::CompositionPayloadType::eKeyPress, + aEvent->mTimeStamp}); + } } } } diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index e99ca2b944a2..29be1eab6e4a 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -1413,11 +1413,6 @@ void nsRefreshDriver::NotifyDOMContentLoaded() { } } -void nsRefreshDriver::RegisterCompositionPayload( - const mozilla::layers::CompositionPayload& aPayload) { - mCompositionPayloads.AppendElement(aPayload); -} - void nsRefreshDriver::RunDelayedEventsSoon() { // Place entries for delayed events into their corresponding normal list, // and schedule a refresh. When these delayed events run, if their document @@ -2060,9 +2055,6 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { TickReasons tickReasons = GetReasonsToTick(); if (tickReasons == TickReasons::eNone) { // We no longer have any observers. - // Discard composition payloads because there is no paint. - mCompositionPayloads.Clear(); - // We don't want to stop the timer when observers are initially // removed, because sometimes observers can be added and removed // often depending on what other things are going on and in that @@ -2359,14 +2351,6 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { MarkerStack::TakeBacktrace(std::move(mViewManagerFlushCause)), transactionId); - // Forward our composition payloads to the layer manager. - nsIWidget* widget = mPresContext->GetRootWidget(); - layers::LayerManager* lm = widget ? widget->GetLayerManager() : nullptr; - if (lm) { - lm->RegisterPayloads(mCompositionPayloads); - } - mCompositionPayloads.Clear(); - RefPtr timelines = TimelineConsumers::Get(); nsTArray profilingDocShells; @@ -2413,9 +2397,6 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { dispatchRunnablesAfterTick = true; mHasScheduleFlush = false; - } else { - // No paint happened, discard composition payloads. - mCompositionPayloads.Clear(); } double totalMs = (TimeStamp::Now() - mTickStart).ToMilliseconds(); diff --git a/layout/base/nsRefreshDriver.h b/layout/base/nsRefreshDriver.h index 2911673e8478..c7081f9cb0e3 100644 --- a/layout/base/nsRefreshDriver.h +++ b/layout/base/nsRefreshDriver.h @@ -28,7 +28,6 @@ #include "mozilla/Maybe.h" #include "mozilla/dom/VisualViewport.h" #include "mozilla/layers/TransactionIdAllocator.h" -#include "LayersTypes.h" class nsPresContext; @@ -394,8 +393,6 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator, EnsureTimerStarted(); } - bool HasPendingTick() const { return mActiveTimer; } - void EnsureIntersectionObservationsUpdateHappens() { // This is enough to make sure that UpdateIntersectionObservations runs at // least once. This is presumably the intent of step 5 in [1]: @@ -411,13 +408,6 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator, mNeedToUpdateIntersectionObservations = true; } - // Register a composition payload that will be forwarded to the layer manager - // if the current or upcoming refresh tick does a paint. - // If no paint happens, the payload is discarded. - // Should only be called on root refresh drivers. - void RegisterCompositionPayload( - const mozilla::layers::CompositionPayload& aPayload); - enum class TickReasons : uint32_t { eNone = 0, eHasObservers = 1 << 0, @@ -585,7 +575,6 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator, // to be called when the timer is re-started and should not influence its // starting or stopping. nsTObserverArray mTimerAdjustmentObservers; - nsTArray mCompositionPayloads; RequestTable mRequests; ImageStartTable mStartTable; AutoTArray, 16> mEarlyRunners; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoJavaSampler.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoJavaSampler.java index 1421a335ebb1..b3ed79172310 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoJavaSampler.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoJavaSampler.java @@ -21,7 +21,7 @@ import java.util.concurrent.LinkedBlockingQueue; import org.mozilla.gecko.mozglue.JNIObject; import org.mozilla.gecko.annotation.WrapForJNI; -// Bug 1618560: Currently we only profile the Android UI thread. Ideally we should +// Bug 1618560: Currently we only profile the Java Main Thread. Ideally we should // be able to profile multiple threads. public class GeckoJavaSampler { private static final String LOGTAG = "GeckoJavaSampler"; diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 51619b40341d..f0b41cf95b25 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -2723,11 +2723,11 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) { // if we can customize it // Pass the samples - // FIXME(bug 1618560): We are currently only profiling the Android UI thread. + // FIXME(bug 1618560): We are currently only profiling the Java main thread. constexpr int threadId = 0; int sampleId = 0; while (true) { - // Gets the data from the Android UI thread only. + // Gets the data from the java main thread only. double sampleTime = java::GeckoJavaSampler::GetSampleTime(sampleId); if (sampleTime == 0.0) { break; @@ -2754,7 +2754,7 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) { // Pass the markers now while (true) { - // Gets the data from the Android UI thread only. + // Gets the data from the java main thread only. java::GeckoJavaSampler::Marker::LocalRef marker = java::GeckoJavaSampler::PollNextMarker(); if (!marker) { @@ -2889,16 +2889,10 @@ static void locked_profiler_stream_json_for_this_process( ProfileBuffer javaBuffer(bufferManager); CollectJavaThreadProfileData(javaBuffer); - // Set the thread id of the Android UI thread to be 0. - // We are profiling the Android UI thread twice: Both from the C++ side - // (as a regular C++ profiled thread with the name "AndroidUI"), and from - // the Java side. The thread's actual ID is mozilla::jni::GetUIThreadId(), - // but since we're using that ID for the C++ side, we need to pick another - // tid that doesn't conflict with it for the Java side. So we just use 0. - // Once we add support for profiling of other java threads, we'll have to - // get their thread id and name via JNI. + // Thread id of java Main thread is 0, if we support profiling of other + // java thread, we have to get thread id and name via JNI. RefPtr threadInfo = new ThreadInfo( - "AndroidUI (JVM)", 0, false, CorePS::ProcessStartTime()); + "Java Main Thread", 0, false, CorePS::ProcessStartTime()); ProfiledThreadData profiledThreadData(threadInfo, nullptr); profiledThreadData.StreamJSON( javaBuffer, nullptr, aWriter, CorePS::ProcessName(aLock),