Skip to content
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

Editing main.lua on Quest 2 using TurboEditor or VIM results in corrupted file and parser errors #3

Closed
timschmidt opened this issue Aug 20, 2021 · 3 comments

Comments

@timschmidt
Copy link

I've been trying to figure out a dev / test loop entirely on the Quest 2.

Seems that editing main.lua in TurboEditor or VIM on the Quest 2 using a bluetooth keyboard, resulting in a slightly smaller file, saving it, then switching to Lodr, or starting Lodr after killing it, always fails.

Reason seems to be parser errors on main.lua (the edited file). When I look at the contents of the file, it's as if the edited version was saved over top of the previous version without unlinking the previous version first. Such that the contents are correct but the file length is longer than it should be - as long as the original version of the file instead of the edited version - and the difference is made up of bytes from the original version.

Not sure exactly what's going on. Seems like a buffer or file IO ordering issue. Advice welcome.

@mcclure
Copy link
Owner

mcclure commented Aug 20, 2021

Okay, sorry, can you clarify?

  1. You're running VIM on the quest? Not syncing with adb?
  2. When you say you "look at the contents of the file"-- you mean that after saving, you inspect the contents of the file, and the contents of the file are garbled? Or do you mean the representation of the contents of the file in lovr's memory?

Lovr should, as far as I know, not be writing to these files or retaining open copies of the files. I don't think any behavior of lovr could be causing this. So what it sounds like to me is that your copy of vim is either broken or is built for linux in a way which does not transfer to Android.

Do you get the garbled files if you edit with vim when lovr is NOT running?

@timschmidt
Copy link
Author

timschmidt commented Aug 21, 2021

1: Yes: https://f-droid.org/en/packages/net.momodalo.app.vimtouch/ Same behavior happens with https://play.google.com/store/apps/details?id=com.maskyn.fileeditor&hl=en_US&gl=US Syncing with ADB or other file transfer methods from a PC works. But editing files directly on the quest results in file corruption.

2: Correct. And file contents are garbled in a very specific way:

This is the last function listed in the main.lua I am testing at the moment:

function load_environment(environment_name)
  app.skybox = lovr.graphics.newTexture({
    left = 'environments/' .. environment_name .. '/left.jpg',
    right = 'environments/' .. environment_name .. '/right.jpg',
    top = 'environments/' .. environment_name .. '/top.jpg',
    bottom = 'environments/' .. environment_name .. '/bottom.jpg',
    back = 'environments/' .. environment_name .. '/back.jpg',
    front = 'environments/' .. environment_name .. '/front.jpg'
  })
  app.ambient = lovr.audio.newSource('environments/' .. environment_name .. '/ambient.ogg')
  app.ambient:setLooping(true)
  app.ambient:play()
end

When I edit that file and save on the quest, the end of the file looks like this:

function load_environment(environment_name)
  app.skybox = lovr.graphics.newTexture({
    left = 'environments/' .. environment_name .. '/left.jpg',
    right = 'environments/' .. environment_name .. '/right.jpg',
    top = 'environments/' .. environment_name .. '/top.jpg',
    bottom = 'environments/' .. environment_name .. '/bottom.jpg',
    back = 'environments/' .. environment_name .. '/back.jpg',
    front = 'environments/' .. environment_name .. '/front.jpg'
  })
  app.ambient = lovr.audio.newSource('environments/' .. environment_name .. '/ambient.ogg')
  app.ambient:setLooping(true)
  app.ambient:play()
end









t_name .. '/ambient.ogg')
  app.ambient:setLooping(true)
  app.ambient:play()
end

Note: the file is the same number of bytes long before and after the edit.

@mcclure
Copy link
Owner

mcclure commented Aug 21, 2021

Do you get the garbled files if you edit with vim when lovr is NOT running?

It sounds like the answer to this question is "yes". In other words, this is not a bug in lovr/lodr, and there is nothing we can do about it. I think you should file your bug on VimTouch, as that appears to be the app with the problem on Quest. (Unfortunately it appears VimTouch is not an active project, though that link has a few suggestions for alternatives.)

If what you are looking for is just advice, I checked with Daniel Micay from the Graphene project (an Android custom ROM) because he is more familiar with Android OSS resources than I am. Daniel said:

It looks like VimTouch has been dead for 7 years. They should probably just be using Vim in Termux.
#offtopic:http://grapheneos.org [Matrix] it a good place to discuss the best apps for different use cases, etc. 1411 people there, and a lot of them primarily using open source apps.

There's information on our Matrix rooms at https://grapheneos.org/contact#community.

Not aware of a better place than our #offtopic:http://grapheneos.org room. There are probably large Matrix and IRC rooms about Android but our community tends to have people around with high quality advice.

I recommend either trying out Termux as both Daniel and the people in the VimToch issue suggest, or asking in the Graphene Matrix channel if anyone knows of a general solution. Good luck

@mcclure mcclure closed this as completed Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants