btrfs icon indicating copy to clipboard operation
btrfs copied to clipboard

Small Aseprite files sometimes get padded to 4KB only on BTRFS

Open vgf89 opened this issue 3 years ago • 5 comments

I'm using WinBTRFS 1.7.9 on Windows 11 Build 22000.194

When saving files with Aseprite (1.3 beta6 or 1.2.29, both exhibit the same problem) on my BTRFS partition, the files get erroneously padded with zeroes to 4KB. Also, if I open and then save the file in Aseprite again on the BTRFS drive, Windows Explorer shows that the file's size go from 4KB back to 3KB for just a moment before changing again to 4KB. None of this strangeness happens on my NTFS or FAT32 drives; they always show the file as 3KB. Even opening and saving the erroneous 4KB file on NTFS and FAT32 changes its size back to 3KB.

Copy and pasting the files around the BTRFS drive doesn't cause the problem. It's strictly when saving from Aseprite, and only a problem on BTRFS.

I'm using whatever default settings BTRFS has on Ubuntu 21.04, and I haven't customized settings in the registry.

Maybe https://github.com/maharmstone/btrfs/issues/277 is related?

I've attached the original good 3KB file, as well as the incorrect 4KB one that I get when saving on the BTRFS drive. I've tried opening and saving the file in other programs (HxD and Notepad++) on the BTRFS drive but they don't exhibit the problem. And yet, since the problem doesn't happen with NTFS or FAT32, and I literally see the file size change from incorrect to correct to incorrect again in Explorer, I suspect this is a BTRFS driver issue.

Due to Aseprite's license I won't attach the program in question here, but I can send it to you privately via email. Let me know what else you might need to track this bug down.

test_files.zip

vgf89 avatar Oct 07 '21 07:10 vgf89

Thanks, I'll try to have a look. Is this a new thing on Windows 11, or did it happen on Windows 10 as well?

maharmstone avatar Oct 07 '21 17:10 maharmstone

I guess I run into the same bug. I tried to reduce it as good as I could, but I think there must be a race condition, so I am not sure.

Anyway, with this python code snipped I could reproduce it:

import json


TESTFILE = 'test.json'

def waist_time():
    j = 0
    for i in range(2**20):
        j += i*i
    return j

data = {}
with open(TESTFILE, 'r') as file:
    data = file.read()
print(waist_time())
data2 = {'a': 'a'}
with open(TESTFILE, 'w') as file:
    file.write(json.dumps(data2))

mogoh avatar Oct 17 '21 10:10 mogoh

Thanks @mogoh, but this works for me. What version of Windows are you on (winver), and what version of Python?

maharmstone avatar Oct 28 '21 20:10 maharmstone

@maharmstone that's annoying. I will see, if I can tweak it to work refillable.

Winver

Version 20H2 (Build 19042.1288)

python --version

Python 3.9.7

mogoh avatar Nov 01 '21 19:11 mogoh

I couldn't get the python file to work when I tested it last. Trying to save the aseprite file on btrfs still causes the issue however. I can literally Save As... onto any other drive and it appears to be 3KB, but saving on my BTRFS drive makes it 4KB, padded with 0s at the end. Happens on both Aseprite 1.3-beta7, Asprite 1.3-beta10 and at least Aseprite 1.2.29 (I haven't tried .30, .31. or .32, but fixes from those were ported to 1.3-beta8).

I can even watch the bug happen if I keep the file open in HxD while saving in Aseprite. If I press Ctrl+S in Aseprite then immediately click my mouse on the HxD window to focus it, HxD will refresh and show the correct 3KB data (for half a second or less) then refresh again to show the erroneous 4KB padded data.

I'm unsure if this happens on Windows 10.

Winver: Version 21H2 (OS Build 22000.376)

vgf89 avatar Jan 18 '22 03:01 vgf89

Closing old issues

maharmstone avatar Nov 30 '23 01:11 maharmstone