Subject: bug#30699: 26.0.91; buffer contents flicker on macOS frames when frames are resized

From: Alan Third <[email-masked]>
Date: Wed, 7 Mar 2018 20:26:03 +0000

On Wed, Mar 07, 2018 at 07:26:01PM +0200, Eli Zaretskii wrote:
> > I’ve tried adding calls to NSDisableScreenUpdates and
> > NSEnableScreenUpdates in redisplay_internal, just to see if it works,
> > but I couldn’t get it to work at all: I always saw the blanked frame.
> > Either these functions don’t work as advertised or there’s something
> > else going on. It’s quite probable I’ve misunderstood
> > redisplay_internal.
> 
> If you tell me where did you try to add these calls and perhaps also
> what was your mental model of what redisplay_internal does when you
> did that, I might be able to help you add this in the right places
> (assuming the idea is workable, and I trust your expertise on that).

updateFrameSize in nsterm.m calls SET_FRAME_GARBAGED, which appears to
just flag the frame for clearing.

My assumption was that redisplay first checks if the frame is garbaged
and if so clears it, then redraws the contents of the frame.

I put the calls to NS(En|Dis)ableScreenUpdates at the start and end of
redisplay_internal:

modified   src/xdisp.c
@@ -13868,7 +13868,7 @@ redisplay_internal (void)
   redisplaying_p = true;
   block_buffer_flips ();
   specbind (Qinhibit_free_realized_faces, Qnil);
-
+  ns_disable_screen_updates ();
   /* Record this function, so it appears on the profiler's backtraces.  */
   record_in_backtrace (Qredisplay_internal_xC_functionx, 0, 0);
 
@@ -14602,7 +14602,7 @@ redisplay_internal (void)
 #endif
   if (interrupt_input && interrupts_deferred)
     request_sigio ();
-
+  ns_enable_screen_updates ();
   unbind_to (count, Qnil);
   RESUME_POLLING;
 }

I realise this isn’t robust, but I was just testing it out.

I imagine my failure here is that ns_clear_frame isn’t called from
redisplay at all, but somewhere else.
-- 
Alan Third