fix map3d on windows - #1719
Merged
Merged
Conversation
the same HOME/LOCALAPPDATA/tempdir fallback is needed by the 3D map for its terrain tile cache
open() was called in text mode and .read() ran before the with, so the fallback entered a str as a context manager and always raised. It is only reached when importlib.resources fails, which is what happens in a frozen build where the data directory is not an importable package.
HOME is not set on native Windows, so the quantized terrain tiles were cached relative to the cwd. For an installed build that is the install directory under Program Files, which is not writable.
vtk is a plain module that fakes a package by pointing __path__ at vtkmodules, which pyinstaller cannot follow. The frozen Windows build died with ModuleNotFoundError: No module named 'vtk.wx'.
MAVExplorer's pyinstaller analysis did not include mavproxy_map/data, so both its 2D map and its 3D map failed to load loading.jpg.
without vtk and quantized-mesh-tile the released installer has no 3D map
sits below Show Map and loads the 3D map module
the viewer imports VTK in a child process, so with the packages absent the child died where nobody could see it and idle_task quietly dropped the map. find_spec keeps VTK out of the parent process.
the existing guard wrapped the map3d import, but map3d.py does not import VTK, so a missing vtk never raised there
the modpaths loop falls back to a bare module name, and its 'No module named X' was overwriting the real failure from the MAVProxy.modules path
a distro opencv is built against one numpy major version, so pulling in a newer numpy leaves cv2 unimportable and the map failed to load with no clue why. MAVProxy itself keeps running either way.
quantized-mesh-tile requires numpy>=2, which leaves a distro opencv or matplotlib built against numpy 1 unimportable, taking out the 2D map and the graphs. The floors are needed because pip leaves an unpinned requirement alone when the distro build already satisfies it.
keeping the first error stopped the fallback bare module name reporting 'No module named X' over the real reason, but it also hid the reason an external plugin failed. A ModuleNotFoundError naming the modpath we tried only says that path does not exist, so let a later attempt replace it.
find_spec only catches packages that are absent, not a VTK or wx that is installed but unusable, and the child's stderr goes nowhere when MAVProxy is started from a GUI. wx raises SystemExit rather than an Exception when it cannot open the display, so catch that too. Also point at the MAVProxy[map3d] extra: 'pip install vtk quantized-mesh-tile' pulls numpy>=2 without the opencv and matplotlib builds to match, which breaks the 2D map on older distros.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
now works both in WSL2 and on native windows