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

Calculates post length incorrectly #4425

Closed
jikamens opened this issue May 6, 2024 · 0 comments · Fixed by #4480
Closed

Calculates post length incorrectly #4425

jikamens opened this issue May 6, 2024 · 0 comments · Fixed by #4480
Assignees
Labels

Comments

@jikamens
Copy link

jikamens commented May 6, 2024

Detailed description

When I go to edit the current version of https://federate.social/@jik/112391392864473951 in the Mastodon web app, it says I have one free character. When I go to edit exactly the same post in Tusky Test 25.0-ad1afdd2, it says the post is 71 characters too long immediately when I start editing it.

My Mastodon server is running version 4.2.8.

Steps to reproduce the problem

  1. Edit a post. I suspect the problem is the links, but that's just a guess, so edit a post with links.
  2. Observe how the length shown in Tusky is different from the length shown when you edit the post in the Mastodon web app.

Debug information

Tusky Test 25.0-ad1afdd2
Google Pixel 8
Android version: 14
SDK version: 34

@jikamens jikamens added the bug label May 6, 2024
@connyduck connyduck self-assigned this May 13, 2024
connyduck added a commit that referenced this issue Jun 2, 2024
At first I thought simply changing the regex might help, but then I
found more and more differences between Mastodon and Tusky, so I decided
to reimplement the thing. I added 74 testcases that I all compared to
Mastodon to make sure they are correct.

On an Fairphone 4 the new implementation is faster, on an Samsung Galaxy
Tab S3 slower.

Testcases for the benchmark:
```
test of a status with #one hashtag http
```
```
test
http:// #hashtag https://connyduck.at/
http://example.org
this is a #test
and this is a @[email protected] @test @test@[email protected]
```
```
@[email protected] Just your ordinary mention with a hashtag
#test
```
```
@[email protected] Just your ordinary mention with a url
https://riot.im/app/#/room/#Tusky:matrix.org
```



FP4:
```
       11.159   ns          15 allocs    Benchmark.new_1
      119.701   ns          43 allocs    Benchmark.new_2
       21.895   ns          24 allocs    Benchmark.new_3
       87.512   ns          32 allocs    Benchmark.new_4

       16.592   ns          46 allocs    Benchmark.old_1
      134.381   ns         169 allocs    Benchmark.old_2
       28.355   ns          68 allocs    Benchmark.old_3
       45.221   ns          77 allocs    Benchmark.old_4
```

SGT3:
```
       43,785   ns          18 allocs    Benchmark.new_1
      446,074   ns          43 allocs    Benchmark.new_2
       78,802   ns          26 allocs    Benchmark.new_3
      315,478   ns          32 allocs    Benchmark.new_4

       42,186   ns          45 allocs    Benchmark.old_1
      353,570   ns         157 allocs    Benchmark.old_2
       72,376   ns          66 allocs    Benchmark.old_3
      122,985   ns          74 allocs    Benchmark.old_4
```


benchmark code is here: https://github.com/tuskyapp/tusky-span-benchmark

closes #4425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants