graphics display bug when using console and Lua draw functions? - General Discussion and Assistance - CHDK Forum supplierdeeply

graphics display bug when using console and Lua draw functions?

  • 7 Replies
  • 6968 Views
graphics display bug when using console and Lua draw functions?
« on: 01 / November / 2013, 14:57:23 »
Advertisements
From time to time I've run into a strange graphics interaction when using the CHDK console and the CHDK Lua drawing functions on the screen at the same time.  Basically, the grey background of the console occasionally escapes from the console area and extends into the area being drawn by the Lua draw commands. 

Here's a couple of screen shots that give an example of the phenomena.  The red oval in the third shot shows the corruption - the grey you see there is outside of the defined console area.  It can look much worse than this when there are more complex graphics than the simple blue box. I tried to keep the example simple here.



Here's the script.  It does the same thing on three of my different camera models so its not a port specific thing.

Code: [Select]
--[[
@title Bleed Test
--]]
require("drawings")
props=require("propcase")
xpos =  70
ypos =  160
box_width = 230
box_height = 32
fg="white"
bg="blue"
set_console_layout(1 ,5, 45, 12 )
draw.add("rectf",  xpos, ypos, xpos+box_width, ypos+box_height, bg, bg)
val2=draw.add("string", xpos+76,  ypos+12, " -" ,  fg, bg)
i=0
repeat
   draw.replace(val2, "string", xpos+76,  ypos+12, "count="..i, fg, bg)
   draw.overdraw()
   if (i==20) then print("test") i=0 else i=i+1 end
   wait_click(100)
until not(is_key("no_key"))
 
Almost looks like an uninitialized variable problem or some weird interaction with the LCD display buffers when they change?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: graphics display bug when using console and Lua draw functions?
« Reply #1 on: 01 / November / 2013, 18:10:29 »
Most likely a task switch at the wrong time

Console is drawn in spytask, lua drawing is done in keyboard task.

Draw code uses global variables so is not really safe.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: graphics display bug when using console and Lua draw functions?
« Reply #2 on: 01 / November / 2013, 18:14:08 »
Draw code uses global variables so is not really safe.
Something that could be fixed simply with a mutex / lock ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: graphics display bug when using console and Lua draw functions?
« Reply #3 on: 01 / November / 2013, 18:20:58 »
Draw code uses global variables so is not really safe.
Something that could be fixed simply with a mutex / lock ?

I'd look at removing the need for global variables first.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


Re: graphics display bug when using console and Lua draw functions?
« Reply #4 on: 01 / November / 2013, 18:23:46 »
I'd look at removing the need for global variables first.
Not having looked at the code,  I was thinking of a q&d solution in case what is there proves to be a bear.

Are you going to look at it or should I?

WW
Ported :   A1200    SD940   G10    Powershot N    G16

Re: graphics display bug when using console and Lua draw functions?
« Reply #5 on: 02 / November / 2013, 12:48:59 »
Patch file to fix this issue attached. 

I can see ways to optimize this code for speed at the cost of code size.  Doesn't seem worth the effort.

Update  : newer patch file attached - previous was a version older and had a syntax error
« Last Edit: 03 / November / 2013, 09:46:04 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: graphics display bug when using console and Lua draw functions?
« Reply #6 on: 03 / November / 2013, 02:49:01 »
Patch file to fix this issue attached. 

I can see ways to optimize this code for speed at the cost of code size.  Doesn't seem worth the effort.

Looks ok. I'm mostly offline for a few more days (and away from build PC).
I can add to SVN on Tuesday evening if reyalp can't do it sooner.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: graphics display bug when using console and Lua draw functions?
« Reply #7 on: 03 / November / 2013, 10:03:50 »
Looks ok. I'm mostly offline for a few more days (and away from build PC).
I can add to SVN on Tuesday evening if reyalp can't do it sooner.
Thanks philmoz.  The patch I uploaded turned out to be one version older than what I tested (fumble fingers) and had an extra comma in one of the function calls.  I fixed that and reposted.  Also posted to the bug fix thread so it doesn't get lost.
Ported :   A1200    SD940   G10    Powershot N    G16


 

Related Topics