Flickering Problem

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Flickering Problem

Post by joel.epsteinBUS31vi » Tue Jul 09, 2013 1:59 pm

Hi all -

I'm almost done with my latest project, but have run into a problem that I can't seem to get past and would greatly appreciate any feedback you might be able to provide.

My app, designed to be run on a Mac or an IBM compatible, is essentially five separate stacks that are all programatically tied together. The idea here is that the user can drag one of these stacks around the screen and the others will follow. Double-clicking on any of the stacks will bring up yet another one in which the user can manipulate the dimensions, colors, and transparency of the others.

Everything is working very well, and I'm pleased with the results. Except for one thing. On my development machine, everything works perfectly (both Mac and emulated PC). Unfortunately, when my client uses the application and drags the stacks around the screen, she experiences a good bit of flickering in the locations where the various stacks join each other. She also experiences the flickering whenever she uses the sliders to adjust the size of the various stacks.

I've contacted tech support, and they can replicate the problem, and suggested that in move stack handler, I set the stack rect instead of the stack loc. Unfortunately, however, doing that seems to make the problem worse.

I'd be ever so grateful if you could let me know what I can do to eliminate that pesky flickering.

Peace.

Joel

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Flickering Problem

Post by shaosean » Tue Jul 09, 2013 10:53 pm

When you move one of the stacks, the other stacks are not being moved until afterwards (as you can see with the flickering).. An external can be made to help use the system calls on Mac OS X and not too certain if there is anything native in Win32 or if you would need to code the magnetic windows yourself..

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Tue Jul 09, 2013 11:48 pm

Once again, thanks so much for taking time to answer my question. And as always, I have a follow-up.

I'm not sure what you mean by:
When you move one of the stacks, the other stacks are not being moved until afterwards
My handlers below seem to be moving all five stacks simultaneously. It seems to work quite nicely (except for that pesky flicker).

Code: Select all

on mouseDown
   if the visible of stack "toolbox" is false then
      put item 1 of the mouseLoc into sgLeftOffset
      put item 2 of the mouseLoc into sgTopOffset
      put item 1 of globalloc(the mouseLoc) into sgStartPosH
      put item 2 of globalloc(the mouseLoc) into sgStartPosV
      put the loc of stack "readerThing" into tPosRT
      put the loc of stack "topStack" into tPosTS
      put the loc of stack "botStack" into tPosBS
      put the loc of stack "closure" into tPosCl
      put the loc of stack "notch" into tPosNo
      put true into sgDragging
   else
      go stack "toolbox"
   end if
end mouseDown

on mouseMove
   if sgDragging is true then
      put item 1 of globalloc(the mouseLoc) - sgStartPosH into tPosH
      put item 2 of globalloc(the mouseLoc) - sgStartPosV into tPosV
      set the loc of stack "readerThing" to (item 1 of tPosRT+tPosH), (item 2 of tPosRT+tPosV)
      set the loc of stack "topStack"      to (item 1 of tPosTS+tPosH), (item 2 of tPosTS+tPosV)
      set the loc of stack "botStack"      to (item 1 of tPosBS+tPosH), (item 2 of tPosBS+tPosV)
      set the loc of stack "closure"        to (item 1 of tPosCl+tPosH), (item 2 of tPosCl+tPosV)
      set the loc of stack "notch"          to (item 1 of tPosNo+tPosH), (item 2 of tPosNo+tPosV)
   end if
end mouseMove
Only rarely do I see the flicker on a Macintosh. It's primarily when I use it on a PC that I see the problem.

Do you see any problem with the code above that may be causing the flicker?

And what would I need to do, as you say:
to code the magnetic windows yourself
I'd be ever so grateful for any suggestions you might have - I'm really in a bind here.

Thanks so much.

Joel

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Flickering Problem

Post by shaosean » Wed Jul 10, 2013 8:17 am

If all the windows moved at the same time, there would be no flickering ;-)

As for writing your own magnetic windows, you would need to look at writing an external (or hacking the source code).. Here is some sample code that you might be able to use in an external http://www.codeproject.com/Articles/604 ... l-forms-to

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Thu Jul 11, 2013 3:27 pm

Thanks for the follow-up. I appreciate the resource.

A couple questions:
- do you think that there really is no way to have LiveCode handle my situation without using an external?
- is there anything I could do to tweak the code to even minimize the flickering?
- I have absolutely no experience working with Externals or coding for the PC (the Mac version doesn't flicker). Do you think it would be best for me to turn to someone else and pay them to write the External, or would it be easy enough for me to struggle through it?

Joel

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Flickering Problem

Post by FourthWorld » Thu Jul 11, 2013 3:32 pm

Have you considered moving the contents of those windows into panes within a single window?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Thu Jul 11, 2013 5:09 pm

Richard -

Thanks for the suggestion. The problem with using separate rects on a single window is that in my program, each one may have a differing level of transparency. I know that I can set the blend level of the rects to achieve this, but I need the underlying stack to be transparent as well (so the user's desktop is visible). And when the underlying stack is transparent, any items in it also take on that level of transparency (for example, if the underlying stack is 20% transparent, I can't have a 100% opaque rect appearing inside the stack).

Any other ideas? I'd appreciate anything you might throw my way.

Thanks so much.

Joel

pkocsis
Posts: 105
Joined: Sat Apr 15, 2006 7:20 am

Re: Flickering Problem

Post by pkocsis » Tue Jul 16, 2013 8:59 pm

Hi Joel,

A few "shot in the dark" suggestions...

Firstly, have you tried changing the syncRate? By default, the syncRate is set to 20. Try lowering it to 2 (I wouldn't recommend lowering it to 1, although you could try that. Lowering it to 1, in my testing, has at times brought CPU's to their knees when you have objects moving).

If 2 helps your situation, then experiment with raising it. It's probably a good idea to use a syncRate only as low as needed in order to solve your problem.

Secondly, is the problem Windows machine windows 7 or Vista? If so, and as a test, try to have your user turn off dwm (desktop composition). Here is a link that gives several methods for doing such:

http://www.sevenforums.com/tutorials/12 ... sable.html

I had an application where fields were "move"ing....setting my syncRate to 2 or 4 GREATLY helped choppiness, as well as writing an external to allow a user to turn off dwn (desktop composition).

I don't know if any of this will help your flicker problem, but these things are certainly worthwhile to try! Hoping that merely adjusting your syncRate way down will do the trick!

Paul

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Tue Jul 16, 2013 9:27 pm

Paul -

Fantastic. Thanks for the advice. I only wish that I wasn't out of the office so I could test this out. I'm itching to get home and try it. I'll report back in a few days. Thanks for providing the suggestions.

Joel

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Flickering Problem

Post by Simon » Tue Jul 16, 2013 9:31 pm

Hi Joel,
Is it possible to take a snapshot of the stacks at drag and actually move that? You know, set the vis of the actual stacks to false and on mouseUp relocate them.
It won't help with the slider issue though.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Wed Jul 24, 2013 2:59 am

Paul -

Unfortunately, my testing has not revealed any significant differences regardless of what syncRate I use. And when I disable Desktop Composition, the problem gets much worse. Bummer.
Nevertheless, I appreciate your suggestions as I'm willing to try just about anything at this point.

Joel

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Wed Jul 24, 2013 3:03 am

Simon -

Thanks for the suggestion about using the snapshot. I've not played with that feature yet. Do you think that solution would work for this situation: I would need to take a snapshot of just the five stacks and they are not arranged in a rectangular shape - plus I need to preserve the specific blend level of each stack in the snapshot. If the snapshot could do both of those things, I think it would be a great solution.

Peace.

Joel

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Flickering Problem

Post by Simon » Wed Jul 24, 2013 5:22 am

Drats, didn't see the blendLevel part, I think a snapshot will capture the background.
I don't know how important this problem is but a workaround would be a custom window and everytime the mouseEnters the titlebar go solid on all windows.

Maybe?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

joel.epsteinBUS31vi
Posts: 135
Joined: Thu Sep 13, 2012 10:25 pm

Re: Flickering Problem

Post by joel.epsteinBUS31vi » Wed Jul 24, 2013 12:44 pm

Thanks, Simon. Unfortunately, the intent of the app is to allow the transparency over the background image. I appreciate the suggestions, though.

Joel

pkocsis
Posts: 105
Joined: Sat Apr 15, 2006 7:20 am

Re: Flickering Problem

Post by pkocsis » Thu Jul 25, 2013 2:57 am

Darnit! hmm...I tried to reproduce the problem using the two handlers you originally posted, but do not experience a flicker problem on my meager Win 7 machine....I wish it had so that I could've tried some things...

A few more (probably useless) thoughts....

Does this happen on *every* windows machine?....or just your test user's machine?

When I ported one of my application to Windows 7, I too had experienced reduced "smooth" moving performance of various items relative to XP....I remember researching graphics drivers and discovered that 2D GPU acceleration schemes had changed greatly from XP to Vista/Win7....to my dismay, "moving" objects on meager XP machines were MUCH smoother than the very same moving objects on beefy Vista/Win7 machines.

All that said, and I have not tested or played with any of this, but have you tried to use acceleratedRendering features? (look up acceleratedRendering in the LC dictionary).

Also, have you tried to surround your "moves" with lock/unlock screen? (might make things worse, but who knows)

lock screen
set your loc's
.
.
unlock screen

Sorry Joel, more shots in the dark!

Again, using your handlers posted above, I tried to reproduce the problem but the window shaped (and 40% blendLevel + slightly overlapped) test stacks that I put together did not flicker at all.....

Paul

Post Reply