AsherGlick / Burrito

An overlay tool for Guild Wars 2 that works on linux
GNU General Public License v2.0
79 stars 18 forks source link

Can't click on burrito buttons - macOS #101

Open Zeluok opened 1 year ago

Zeluok commented 1 year ago

System: macOS 12.6, M1 Silicon (arm64)

I use a mac and experience the same errors as everyone else in the linux community with taco 066r over wine. I've tried 032r but taco's transparency doesn't work and all of GW2 ends up with a black overlay despite being responsive and displaying all overlays.

I've since tried to get Burrito working, to do so I've made the following changes:

With those changes, I exported a burrito.osx.app for myself. To then run Burrito, I used the following steps:

  1. start GW2 (using a wineskin app bundle that I use regularly), login and travel to a map
  2. start cmd from within the running wineskin (thereby granting all wine ENV variables to child processes)
  3. go to and start ./burrito_link.exe from within command prompt session
  4. from a mac terminal, run the burrito binary from within the burrito.osx.app bundle (./Contents/MacOS/burrito)

Having done all this, I get std out from both burrito processes and can see that burrito_link is periodically updated with gw2 info (my character, it's map, world etc.). burrito_link shows no visible errors and appears to function well.

However, the exported burrito binary does not work completely. The burrito binary/overlay starts up with it's splash and then creates the transparent burrito icon as expected. However:

Some good news though, the output from the overlay says:

Before reaching this point, I was able to click on the icon and see the main burrito menu when accidentally errored on TacoParser.new() by forgetting to link the dylib. Not sure why I can't click on the burrito icon now, nor where/how XQuartz is being loaded.

Appreciate any help.

Zeluok commented 1 year ago

Some other notable things, perhaps they help unpack the state and relevance of XQuartz:

When using the version of burrito that wasn't linked to libgw2_taco_parser.dylib, showing red borders helped reveal that the window wasn't properly sized.

Once linking was corrected, I couldn't navigate to the menu to have red borders appear, but it appeared to be closer to the right spot.

In both cases, I'm using windowed mode, rather than windowed fullscreen. The overlay only shows this way. However, the overlay icon is placed in the titlebar (above the game viewport).

Moving my window doesn't move the icon in either case.

AsherGlick commented 1 year ago

Really cool to hear that it even launches on mac. Fair warning I know very little about the macos compositor and even less about xquartz.

I am guessing the inability to click is related to a specific issue in the window manager, unfortunately this is something that would need to be investigated by someone like yourself who has access to the hardware. There are two places I think would be good places to start to look, one is the x11 interface burrito-fg which sets specific x11 flags to make the overlay behave properly on a wider range of desktop environments. The second is within the godot code, probably within the functions set_minimal_mouse_block() and set_maximal_mouse_block() and they control which pixels should have clicks captured vs let through to the window below.

The red borders are enabled via the latter function to indicate to the user that clicking anywhere in the window should pull focus to burrito and not anything behind it. The red borders should pop up when clicking on the burrito icon in the top left but maybe you can try to have that function get called on start in the _ready() function of Spatial.gd if the top left button is behind hidden by some system UI. You can always try commenting out certain x11 or mouse commands to see if removing them causes any change in behavior too.

Windowed mode is not supported in burrito right now, the screen size should adjust to match the size of the window but the position will not update automatically yet. This is probably possible to do but none of the contributors so far have needed it. I personally play in windowed fullscreen.

Most of the linux issues are caused by window manager or desktop environment quirks, but also wayland does not yet allow you to do many things that x11 did so there are some things that are just not possible if using wayland.

While supporting MacOS is not a primary goal for me I am planning to commit to supporting community development on platforms I cannot develop for myself, so if you find any solutions to your issues feel free to submit them as a PR. Hopefully that helps and I will try to answer any other questions you run into if I can.

Zeluok commented 1 year ago

Turns out burrito-fg thread was hung on fn get_window_geometry in lib.rs. I commented it out and hardcoded geometry.

Basic overlay works!

image
Zeluok commented 1 year ago

I had to do some more hardcoding (decode_context_packet)-

var identity_bytes = spb.get_data(identity_length)
var identity_str = "{\"fov\": 1.22}"

But it now works-

image

Not sure why I get this otherwise:

ERROR: Condition "err != OK" is true. Returned: String()
   at: get_utf8_string (core/io/stream_peer.cpp:326)
ERROR: Error parsing JSON at line 0: 
   at: parse (core/bind/core_bind.cpp:3267)
SCRIPT ERROR: Invalid get index 'fov' (on base: 'Nil').
          at: decode_context_packet (res://Spatial.gdc:316)

id length is 1634607739, but spb.get_utf8_string(identity_length) fails, as above.

AsherGlick commented 1 year ago

It looks like there is some issue with the 3D textures of the trail. This is very strange to see because those same textures are clearly being properly loaded in the minimap.

Do you have a link to your changes? The identity length being 1634607739 does not make a ton of sense as a real value.

The data transferred from burrito link needs to be read sequentially, any chance that something else is reading, some bytes which is causing this value to be parsing incorrect memory offset?

1634607739 -> 01100001 01101110 00100010 01111011 01100001 -> a 01101110 -> n 00100010 -> " 01111011 -> {

Swapping the endian, this looks like the first four bytes of the identity {"name": ... (https://wiki.guildwars2.com/wiki/API:MumbleLink#Example)

Zeluok commented 1 year ago

https://github.com/Zeluok/Burrito/tree/feature/macbuild Code uploaded. Some stuff was changed by 3.5.1 godot on export - couldn't prevent it. I've put those changes in a separate commit.

image

While at divinity's reach, burrito_link returned the following output. (Verdant Brink switched to Map ID 1052)

image

Burrito log follows. tw_ALL_IN_ONE/tw_exp01_hot01_verdantbrink.xml Is the XML I'm using. It's from Tekkit Workshop's all-in-one pack. .taco or .trl don't seem supported by burrito, so I've only tried with *.xml

To get to the xmls, unpack the .taco as a .zip.

me@M1 ~ % /Applications/burrito.osx.app/Contents/MacOS/burrito 
arguments
0: /Applications/burrito.osx.app/Contents/MacOS/burrito
Current path: /Users/me
Godot Engine v3.5.1.stable.official.6fed1ffa3 - https://godotengine.org
OpenGL ES 3.0 Renderer: Apple M1
Async. shader compilation: OFF

UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
Registered camera FaceTime HD Camera with id 1 position 0 at index 0
    1 | shader_type spatial;
    2 | //render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
    3 | render_mode unshaded, blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx;
    4 | 
    5 | uniform sampler2D texture_albedo : hint_albedo; // TODO: Make instance uniform sampler2D when 4.0 is released
    6 | uniform vec2 map_size;
    7 | uniform bool map_flipped;
    8 | uniform float map_bottom_offset = 36.0;
    9 | 
   10 | uniform float interval = 1.0;
   11 | 
   12 | void vertex() {}
   13 | 
   14 | 
   15 | 
   16 | 
   17 | void fragment() {
   18 |     if (SCREEN_UV.x * VIEWPORT_SIZE.x > VIEWPORT_SIZE.x - map_size.x) {
   19 |         if (map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y > VIEWPORT_SIZE.y - map_size.y) {
E  20->             return;
   21 |         }
   22 |         if (!map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y < map_size.y + map_bottom_offset) {
   23 |             return;
   24 |         }
   25 |     }
   26 | 
   27 |     vec2 base_uv = vec2(UV.y, -UV.x * interval);
   28 |     base_uv = vec2(UV.x, -UV.y);
   29 |     vec4 albedo_tex = texture(texture_albedo,base_uv);
   30 |     ALBEDO = albedo_tex.rgb;
   31 |     ALPHA = albedo_tex.a;
   32 |     //EMISSION = albedo_tex.rgb;
   33 |     //METALLIC = 0.0;
   34 |     //ROUGHNESS = 1.0;
   35 |     //SPECULAR = 0.0;
   36 | }
   37 | 
SHADER ERROR: Using 'return' in 'fragment' processor function results in undefined behavior!
          at: (null) (:20)
    1 | shader_type spatial;
    2 | render_mode cull_back, unshaded;
    3 | uniform sampler2D texture_albedo : hint_albedo;
    4 | 
    5 | uniform vec2 map_size;
    6 | uniform bool map_flipped;
    7 | uniform float map_bottom_offset = 36.0;
    8 | 
    9 | 
   10 | //uniform float smallest_scale = 0.3;
   11 | uniform float smallest_scale = 0.0;
   12 | 
   13 | void vertex() {
   14 |     float dist = max(-MODELVIEW_MATRIX[3].z * smallest_scale, 1.0);
   15 |     VERTEX = (CAMERA_MATRIX * vec4(VERTEX,0)).xyz * dist;
   16 | }
   17 | 
   18 | 
   19 | 
   20 | 
   21 | void fragment() {
   22 |     if (SCREEN_UV.x * VIEWPORT_SIZE.x > VIEWPORT_SIZE.x - map_size.x) {
   23 |         if (map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y > VIEWPORT_SIZE.y - map_size.y) {
E  24->             return;
   25 |         }
   26 |         if (!map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y < map_size.y + map_bottom_offset) {
   27 |             return;
   28 |         }
   29 |     }
   30 |     
   31 |     
   32 |     vec2 base_uv = UV;
   33 |     vec4 albedo_tex = texture(texture_albedo,base_uv);
   34 |     ALBEDO = albedo_tex.rgb;
   35 |     ALPHA = albedo_tex.a;
   36 | }
   37 | 
SHADER ERROR: Using 'return' in 'fragment' processor function results in undefined behavior!
          at: (null) (:24)
accepted peer: 127.0.0.1:49867
Setting transient for
Successfully set transient property!
id length 1634607739
identity_str: {"fov": 1.22}
New Map
Saving Old Map
Loading New Map
id length 1634607739
identity_str: {"fov": 1.22}
id length 1634607739
identity_str: {"fov": 1.22}
New Map
Saving Old Map
Loading New Map
Loading XML file from path /Users/me/Downloads/tw_ALL_IN_ONE/tw_exp01_hot01_verdantbrink.xml
id length 1634607739
identity_str: {"fov": 1.22}
id length 1634607739
identity_str: {"fov": 1.22}
id length 1634607739
identity_str: {"fov": 1.22}
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object.cpp:2070)
ERROR: Resources still in use at exit (run with --verbose for details).
   at: clear (core/resource.cpp:417)

The WARNING and ERROR at the end come irrespective of whether I press quit from the apple dock, or the exit menu button from within burrito.

The id length and identity_str print msgs are in the feature branch.

Zeluok commented 1 year ago

Fixed the weird shaders!

Just removed the return in both icon.tscn and route.tres.

I used

bool dofoo = true;
if (etc)
    if (etc)
        dofoo = false;
    if (etc)
        dofoo = false;

if (dofoo)
    vec2 base_uv = etc

Same as this: https://github.com/godotengine/godot/issues/39863

image
asmaloney commented 1 year ago

@Zeluok Did you ever get this working fully? I'm interested in using it/developing on a Mac as well...

Zeluok commented 1 year ago

AFAIK, works as intended. The write-up above summarises how I got it to work.

However, I've stopped running GW2 on MacOS recently - I use an M1 and it emulates Intel over Rosetta which has a performance penalty in WvW zergs!

It's perfectly fine for fractals, PvP or open world with arcdps, vulkan fps overlays and burrito.

asmaloney commented 1 year ago

Ah - thank you. I thought since the issue was still open that it wasn't fully resolved.

performance penalty in WvW zergs

I'm not much of a WvW player anyways 😆

I'll give it a shot when I find some time!