Board index FlightGear Development Canvas

Why is my plugin's canvas widget showing as a white box ?  Topic is solved

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Why is my plugin's canvas widget showing as a white box ?

Postby TheEagle » Thu Aug 26, 2021 8:16 pm

I am working on the LandingChallenge plugin, together with danielHL, and I am having a weird issue: The plugin popups a canvas widget containing an icon and some text upon landing. This worked correctly until today. Then it suddenly showed only a white box instead of the canvas widget. I did do changes to the code, but even after moving the modified code somewhere where FG doesn't find it ad using a fresh git clone containing the previously working code, the problem persists !! The other canvas boxes work fine - mouse mode changes, PFD's, etc. Something maybe worth adding is that I once ha an aircraft that made all canvas widgets show just white. When switching to another aircraft the canvas widgets showed fine again. Sadly I do not remember which aircraft it was. So: which are the reasons a canvas widget would not display it's contents ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby Hooray » Thu Aug 26, 2021 8:33 pm

Unless you'd like people to post their guesses here, it might be a good idea to share your code :wink:

PS: Are those actual Canvas Widgets using the Widget.nas API or what are you referring to ?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Thu Aug 26, 2021 8:36 pm

Hooray wrote in Thu Aug 26, 2021 8:33 pm:Unless you'd like people to post their guesses here, it might be a good idea to share your code :wink:

The code can be found here: https://github.com/TheFGFSEagle/LandingChallenge
The definition of the widget I have problems with is in landingNotification.nas, the event listener that creates and shows the widget is set up in landingChallenge.nas.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby Hooray » Thu Aug 26, 2021 8:46 pm

Something maybe worth adding is that I once ha an aircraft that made all canvas widgets show just white. When switching to another aircraft the canvas widgets showed fine again. Sadly I do not remember which aircraft it was. So: which are the reasons a canvas widget would not display it's contents ?


For starters, I'd use the property browser and navigate to the canvas, it should have a "status" / "status-msg" property, and you can also check whether the hierarchy is what you expect it to be:

Image

If the status/tree hierarchy look fine, I'd check whether you're applying any custom effects/shaders that could turn the canvas white.

Another idea would be deleting/renaming (moving) your autosave.xml file to see if recreating that has any effect or not
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Thu Aug 26, 2021 9:10 pm

Hooray wrote in Thu Aug 26, 2021 8:46 pm:Another idea would be deleting/renaming (moving) your autosave.xml file to see if recreating that has any effect or not

:lol: I just thought of that as well ! :mrgreen:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Thu Aug 26, 2021 9:31 pm

Hooray wrote in Thu Aug 26, 2021 8:46 pm:If the status/tree hierarchy look fine, I'd check whether you're applying any custom effects/shaders that could turn the canvas white.

Another idea would be deleting/renaming (moving) your autosave.xml file to see if recreating that has any effect or not

I'm not applying any shaders or effects. The property tree of the canvas texture looks good to me:
Code: Select all
 texture[4]/
 .   status = 0 (INT)
 .   status-msg = 'Ok' (STRING)
 .   size = 1000 (DOUBLE)
 .   size[1] = 800 (DOUBLE)
 .   view = 500 (DOUBLE)
 .   view[1] = 400 (DOUBLE)
 .   placement/
 .   .   type = 'window' (STRING)
 .   .   index = 2 (DOUBLE)
 .   .   status-msg = 'Ok' (STRING)
 .   name = 'Landing Notification' (STRING)
 .   background = 'rgba(0,0,0,1)' (STRING)
 .   group/
 .   .   image/
 .   .   .   source/
 .   .   .   .   normalized = 1 (BOOL)
 .   .   .   .   right = 1 (FLOAT)
 .   .   .   .   bottom = 1 (FLOAT)
 .   .   .   id = 'background' (STRING)
 .   .   .   src = '/mnt/DATEN/blender-2.83.0-linux64/2.83/datafiles/colormanagement/filmic/fgfs-addons/LandingChallenge/gui/images/tooltip.png' (STRING)
 .   .   .   size = 234.375 (FLOAT)
 .   .   .   size[1] = 72.06249999999999 (FLOAT)
 .   .   .   slice = '17 fill' (STRING)
 .   .   .   update = 1 (BOOL)
 .   .   image[1]/
 .   .   .   source/
 .   .   .   .   normalized = 1 (BOOL)
 .   .   .   .   right = 1 (FLOAT)
 .   .   .   .   bottom = 1 (FLOAT)
 .   .   .   id = 'warning-icon' (STRING)
 .   .   .   src = '/mnt/DATEN/blender-2.83.0-linux64/2.83/datafiles/colormanagement/filmic/fgfs-addons/LandingChallenge/gui/images/planeLanding.png' (STRING)
 .   .   .   size = 32 (FLOAT)
 .   .   .   size[1] = 32 (FLOAT)
 .   .   .   tf[1]/
 .   .   .   .   m = 1 (DOUBLE, #1)
 .   .   .   .   m[1] = 0 (DOUBLE, #1)
 .   .   .   .   m[2] = 0 (DOUBLE, #1)
 .   .   .   .   m[3] = 1 (DOUBLE, #1)
 .   .   .   .   m[4] = 17 (DOUBLE, #1)
 .   .   .   .   m[5] = 17 (DOUBLE, #1)
 .   .   text/
 .   .   .   id = 'landing-description' (STRING, L1, #1)
 .   .   .   text = 'You landed!\n\n Click for more details...' (STRING, L1, #1)
 .   .   .   alignment = 'left-top' (STRING, L1, #1)
 .   .   .   character-size = 14 (DOUBLE, L1, #1)
 .   .   .   character-aspect-ratio = 1 (DOUBLE, L1, #1)
 .   .   .   font = 'LiberationFonts/LiberationSans-Bold.ttf' (STRING, L1, #1)
 .   .   .   fill = 'rgb(25,25,25)' (STRING, L1, #1)
 .   .   .   draw-mode = 1 (INT, L1, #1)
 .   .   .   tf[1]/
 .   .   .   .   m = 1 (DOUBLE, #1)
 .   .   .   .   m[1] = 0 (DOUBLE, #1)
 .   .   .   .   m[2] = 0 (DOUBLE, #1)
 .   .   .   .   m[3] = 1 (DOUBLE, #1)
 .   .   .   .   m[4] = 59 (DOUBLE, #1)
 .   .   .   .   m[5] = 17 (DOUBLE, #1)
 .   .   .   max-width = 424 (DOUBLE, L1, #1)
 .   .   .   update = 1 (BOOL, L1, #1)


Moving the autosave_2020.4.xml file away didn't help either :x . The weirdest is - it worked until yesterday !!! :shock: :roll: :?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Fri Aug 27, 2021 12:42 pm

I've found out what causes the canvas widget to show up just white. There are two reasons:
  1. Some other part of FG shows a canvas widget in that area (the plugin's widget is shown in the same place the "The scenery ... contains errors. Click for more details" tooltip shows up when using erroneous scenery). After that, I get only a white plugin widget. All other canvas widgets are not white, though.
  2. I reload the plugin. After that, I get a white plugin widget, but all other canvas widgets are as in cause 1 shown normally.

Both can be fixed by restarting FG - but honestly, I can't restart FG just to test the line of code I just added or the typo I fixed ? I spotted this in the output of FG:
Code: Select all
   84.18 [INFO]:nasal      Failed to add command:show-landing-notification-popup : likely a duplicate name :
 at /home/user/fgfs-addons/LandingChallenge/landingNotification.nas, line 159

show-landing-notification-popup is the fgcommand registered on plugin load that shows the problematic canvas widget upon landing. I will try if unregistering the fgcommand with removecommand will maybe fix this whole issue. Else, I've run out of ideas.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Fri Aug 27, 2021 1:36 pm

Sadly, adding removecommand to the plugin's unload function did not help. What else can I try ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Fri Aug 27, 2021 2:38 pm

Partial solution found - always delete the canvas and create a new one when the widget is shown. It works for the moment, but it's probably not an ideal solution regarding performance / memory ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby Hooray » Sat Aug 28, 2021 10:13 am

If you are using the actual Canvas Widget API (Widget.nas), the you also need to look at layouts and DefaultStyle.nas specifically to make it work.
If in doubt, reduce your source code to come up with a reproducible test case that can be executed via the Nasal console - if it's working there, it should also work as an addon, unless you're overwriting a symbol/namespace accidentally

https://wiki.flightgear.org/Howto:Creat ... GUI_Widget
Image

For a list of existing widgets (examples), refer to: https://wiki.flightgear.org/Canvas_widget_matrix

The layout system is introduced here: https://wiki.flightgear.org/Canvas_layout_system
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Sat Aug 28, 2021 11:50 am

Thank you Hooray for the lecture ! Actually it works now - I can do what I want - there is no way to get the white box instead of the popup ! I don't know why though …
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Tue Aug 31, 2021 8:08 pm

I am getting a white box again, don't know why it worked … Anyways, I've found the "real" cause: I went digging into "/sim/gui/canvas", and I found out the following:

At first , the popup shows fine (black, with icon and text). At this point, the above mentioned property node has two "window" subnodes : "window" and "window[1]". By toggling these nodes visibility attribute, I found out that "window" is some tooltip of one of the planes instruments, and "window[1]" is the node of my popup. Now, I reload my plugin. When I make the popup show again, I get the white box ! But now comes the interesting part: I now got a "window[2]" node ! If I toggle window[2]'s visibility, I can show and hide the white box. Now I went to the Nasal console, and deleted that window[2] node with "props.getNode("/sim/gui/canvas/window[2]").remove();", and made my popup show again. And I got my fully functional popup instead of the white box !!! :D

Now I want to determine at runtime that additional node. how can I do that ? If I hardcode it, I might remove the node of another plugin by accident, which I don't want of course !
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby Hooray » Wed Sep 01, 2021 8:03 pm

that would seem to suggest that you are not using the API properly, you're properly invaliding some symbols in a namespace (e.g. via variable shadowing).
In general, that's the type of thing that happens due to misuse of the API, so I'd suggest to carefully review your code / examples
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Why is my plugin's canvas widget showing as a white box

Postby TheEagle » Wed Sep 01, 2021 10:41 pm

@Hooray: I will do that, but I don't think that's the cause, because the code for the popup was basically copy-pasted from ErrorNotification.nas. We just changed a few Strings and added a callback so the data dialog is shown. I am now successful in deleting the orphaned canvases / windows, one has now to reload the plugin twice - if you reload it once and show the popup, it's just not appearing - probably because of the deleting. One has to reload it, then show the popup, then reload again, after that it's working fine.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Why is my plugin's canvas widget showing as a white box

Postby Hooray » Fri Sep 03, 2021 7:13 am

I doubt that, or are you also seeing the same kind of problem when running any of the Canvas snippets ?

as far as I can tell, having to delete/recreate a Canvas for it to function properly is always a bug in your own code. I once had something similar and it was indeed using symbols/variables already in use by the Canvas API itself, which I didn't notice until the problem showed up.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Next

Return to Canvas

Who is online

Users browsing this forum: No registered users and 5 guests