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
Use of http
package should be moved to dio
#1927
Comments
After all the work of #1928, the problem is not fixed ( (In spite of this, it's still probably a good idea to use |
I tried debugging this on the server too, at the point where the requests came in to It looks like the delay issue is in the Android emulator. If I run with the same debug build on a physical device, against the same server instance, the response times are no longer erratic. I'll close this, but I will leave the PR open, since the dio port is probably a worthwhile improvement. |
For the record, here is the reason why HTTP requests can be very slow in Flutter: |
When I demo'd my app to the Serverpod team, numerous times queries took 1 or more seconds (the worst response time was about 8 seconds). This is for only 50 items in the database.
I have looked into this more closely, and the problem is definitely not happening on the server (total endpoint runtime is consistently low). The problem happens at this line, in
serverpod_client_io.dart
:I have absolutely no idea why closing a request would take this long, but profiling in Dart is utterly useless and broken (I tried), and the
http
library is nearly impossible to properly debug because it was written back beforeasync
/await
(even before null-safety and generics...).I have had other bad experiences with
http
before, and I have seen numerous reports online of other people running into problems withhttp
. The Dart team don't seem interested in rewriting it or even updating it to modern Dart.I filed a bug about this here, but I don't anticipate seeing any action on this:
dart-lang/http#1134
The best fix for Serverpod is almost certainly to move from
http
todio
for sending requests to the server.The text was updated successfully, but these errors were encountered: