[Problem] The main display event queue (used by the render-thread) has events which keep building up
[Cause] We do not handle these events.
[Solution] Check events when we render and flush the queue if there are any events.
Change-Id: I53ebdfdb8ac5acbf0dff0698becf082af3d4196a
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
// render loop, we stay inside here when rendering
while( running )
{
+ // Consume any pending events
+ ConsumeEvents();
+
// Check if we've got updates from the main thread
CheckForUpdates();
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", mGLES.GetString(GL_EXTENSIONS));
}
+void RenderThread::ConsumeEvents()
+{
+ // tell surface to consume any events to avoid memory leaks
+ mCurrent.surface->ConsumeEvents();
+}
+
void RenderThread::CheckForUpdates()
{
// atomic check to see if we've got updates, resets the flag int
void InitializeEgl();
/**
+ * Check if display has events
+ * Called from render thread
+ */
+ void ConsumeEvents();
+
+ /**
* Check if main thread posted updates
* Called from render thread
*/
}
}
+void RenderSurface::ConsumeEvents()
+{
+ // if the render surface has own display, check events so that we can flush the queue and avoid
+ // any potential memory leaks in X
+ if( mOwnDisplay )
+ {
+ // looping if events remain
+ int events( 0 );
+ do
+ {
+ // Check if there are any events in the queue
+ events = XEventsQueued( mMainDisplay, QueuedAfterFlush );
+
+ if ( events > 0 )
+ {
+ // Just flush event to prevent memory leak from event queue as the events get built up in
+ // memory but are only deleted when we retrieve them
+ XEvent ev;
+ XNextEvent( mMainDisplay, &ev );
+ }
+ }
+ while( events > 0 );
+ }
+}
+
void RenderSurface::SetDisplay( boost::any display )
{
// the render surface can be passed either EFL e-core types, or x11 types
virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface );
/**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ConsumeEvents()
+ */
+ virtual void ConsumeEvents();
+
+ /**
* @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
*/
virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface ) = 0;
/**
+ * Consumes any possible events on the queue so that there is no leaking between frames
+ */
+ virtual void ConsumeEvents() = 0;
+
+ /**
* Invoked by render thread before Core::Render
* @param[in] egl The Egl interface
* @param[in] glAbstraction OpenGLES abstraction interface