-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WGLMakie] Constantly getting Invalid text boundingbox
errors.
#4109
Comments
That's just the position of the text plot. And text plots can come from a lot of places, like ticks and labels used in the files under makielayout/blocks, lineaxis.jl, some plot recipes like barplot or tooltip... |
Are you using some kind of transform function, or axis scale? Are there any annotations or text plotted directly into the axis? |
Invalid text boundingbox
errors.Invalid text boundingbox
errors.
Alright here's the MWE to repo:
Seems to be caused by repeated x values, when plotting stairs. The error happens when mousing over the (2, 3) point. |
Might be related to #3672, as the error doesn't happen with GLMakie. |
Yep, 100% related. I can fix it locally by modifying Makie.jl/src/interaction/ray_casting.jl Lines 284 to 288 in 12d0e67
with:
The work around is to monkey patch position_on_plot when running WGLMakie. The real fix is to make the index returned by the GLMakie/WGLMakie shaders consistent. Given that the code in main works with GLMakie and the monkey patched version works with WGLMakie, it really doesn't matter which convention is used. It just needs to be consistent. |
I've done a bit more testing with this patch. As a bandaid can't |
I'd rather just fix #3672 directly. That's probably just adding a In GLMakie these are set in https://github.com/MakieOrg/Makie.jl/blob/master/GLMakie/assets/shader/lines.vert and https://github.com/MakieOrg/Makie.jl/blob/master/GLMakie/assets/shader/line_segment.vert as |
That would be best, I have no experience with shaders so I had no sense of scope for the real fix. Out of curiosity, why does WGLMakie use |
I think fixing WGLMakie is probably easier, but that still leaves an open question about the "intuitiveness" of the index. From #3672:
Would imply that adding 1 to the WGLMakie index would break what the user expects. To correct this, should |
Ultimately because WebGL doesn't support geometry shaders. In short GLMakie pushes the positions to the GPU, which then generates quads for the line segments in the geometry shader. WGLMakie generates a quad on CPU and pushes that with positions etc to the GPU, where it gets adjusted to fit the current segment.
I would say matching GLMakie would be best for now. We tend to see GLMakie as the source of truth for backend differences, so it's easier to call this a bug fix if we just make WGLMakie match. Changing GLMakie/both to be intuitive would be breaking imo and probably involves aa good amount of discussion on what's intuitive |
Looks like WGLMakie shaders need more fixing. When mousing over the last segment, the index returned by WGLMakie is larger than the step array. For this specific example, the stairs data is 15 element long but the index returned by
This snippet works well in GLMakie. |
Oh I forgot about NaNs. Three.js (or WebGL?) refuses to even try rendering when there is a NaN involved in vertex/instance data, so when there is we pad out the inputs. If that's part of the issue I should probably work on this myself... More detailsEach line segment uses 4 line points for rendering with lines, because joints require information about the previous and next segment. With that each segment needs a valid (previous, start, end, next) line point in order to draw. The points [1.0, 1.0]
[1.0, 2.0]
[2.0, 2.0]
[2.0, 3.0]
[NaN, 3.0]
[NaN, 4.0]
[3.0, 4.0]
[3.0, 5.0]
[4.0, 5.0]
[4.0, 6.0]
[NaN, 6.0]
[NaN, 7.0]
[5.0, 7.0]
[5.0, 8.0]
[6.0, 8.0] With padding these become: x [1.0, 1.0]
0 [1.0, 1.0]
1 [1.0, 2.0]
2 [2.0, 2.0]
3 [2.0, 3.0]
4 [2.0, 3.0]
5 [NaN, 3.0]
6 [NaN, 4.0]
7 [3.0, 4.0]
8 [3.0, 4.0]
9 [3.0, 5.0]
10 [4.0, 5.0]
11 [4.0, 6.0]
12 [4.0, 6.0]
13 [NaN, 6.0]
14 [NaN, 7.0]
15 [5.0, 7.0]
16 [5.0, 7.0]
17 [5.0, 8.0]
x [6.0, 8.0]
x [6.0, 8.0] The numbers should match the instance index where the point is considered the start point. I'm guessing the 0 index -> 1 index happens in pick. Otherwise this matches up with the indices you see when picking your example. |
Thanks for the details explanation about padding! If I'm not mistaken, shaders can have meta data attached to them. In which case the padding count/offset can be attached to each point and then subtracted from the index before it's returned to |
By the way, as an alternative to padding |
Replacing
What pitfalls do you see with this approach? |
I'd have to get back into that code to give you a good answer, but the duplication is important to detect line starts/ends and the NaN is important to separate the line pieces atm. That information probably needs to get pushed through a new instance buffer for lines to work correctly. Closed line loops may also need some special care here |
Three.js handles |
0.21.8
Yes
MacOS
Unfortunately, I don't have a MWE right now. It's much easier to repro with a complex figure. I've been trying to debug this locally and would like some pointers from the devs.See #4109 (comment) for MWE.I've narrowed it down to this function:
Specifically the first case,
pos
is invalid becausex.position[]
is[NaN, NaN, NaN]
whenx.space[] == x.markerspace[]
. What are some reasons that makex.position[]
invalid and where can I poke around next?The text was updated successfully, but these errors were encountered: