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

[firebase_performance]: HTTP request fails when combined with cupertino_http #17095

Open
1 task done
koji-1009 opened this issue Feb 14, 2025 · 8 comments
Open
1 task done
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: performance type: bug Something isn't working

Comments

@koji-1009
Copy link

koji-1009 commented Feb 14, 2025

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Performance

Which platforms are affected?

iOS

Description

Adding firebase_performance to dependencies to a project using the cupertino_http package causes HTTP requests to fail, which is not a problem with the http package.

Reproducing the issue

Create the following application.

import 'package:cupertino_http/cupertino_http.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Demo', home: const MyHomePage());
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _httpResponse = '';
  String _cupertinoHttpResponse = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('HTTP Request Example')),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16),
        child: SizedBox(
          width: double.infinity,
          child: Column(
            children: [
              Text('http package'),
              ElevatedButton(
                onPressed: () async {
                  final client = Client();
                  try {
                    final response = await client.get(
                      Uri.parse('https://httpbin.org/get'),
                    );
                    setState(() {
                      _httpResponse = response.body;
                    });
                  } on Exception catch (e) {
                    setState(() {
                      _httpResponse = e.toString();
                    });
                  } finally {
                    client.close();
                  }
                },
                child: const Text('Make HTTP Request'),
              ),
              Text('http package response:'),
              Text(_httpResponse),
              const SizedBox(height: 16),
              Text('cupertino_http package'),
              ElevatedButton(
                onPressed: () async {
                  final client = CupertinoClient.defaultSessionConfiguration();
                  try {
                    final response = await client.get(
                      Uri.parse('https://httpbin.org/get'),
                    );
                    setState(() {
                      _cupertinoHttpResponse = response.body;
                    });
                  } on Exception catch (e) {
                    setState(() {
                      _cupertinoHttpResponse = e.toString();
                    });
                  } finally {
                    client.close();
                  }
                },
                child: const Text('Make HTTP Request'),
              ),
              Text('cupertino_http package response:'),
              Text(_cupertinoHttpResponse),
            ],
          ),
        ),
      ),
    );
  }
}

Check the behaviour in the case where firebase_performance is not added to pubspec.yaml and in the case where it is.

dependencies:
  flutter:
    sdk: flutter
  
  http: ^1.0.0
  cupertino_http: ^2.0.0

  firebase_core: ^3.0.0
  firebase_performance: ^0.10.0

Firebase Core version

3.11.0

Flutter Version

3.29.0

Relevant Log Output

Flutter dependencies

Expand Flutter dependencies snippet
$ flutter pub deps -- --style=compact
Dart SDK 3.7.0
Flutter SDK 3.29.0
pefromance_urlsession 1.0.0+1

dependencies:
- cupertino_http 2.0.2 [async ffi flutter http http_profile objective_c web_socket]
- firebase_core 3.11.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_performance 0.10.1+2 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- http 1.3.0 [async http_parser meta web]

dev dependencies:
- flutter_lints 5.0.0 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]

transitive dependencies:
- _flutterfire_internals 1.3.51 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.12.0 [collection meta]
- boolean_selector 2.1.2 [source_span string_scanner]
- characters 1.4.0
- clock 1.1.2
- collection 1.19.1
- fake_async 1.3.2 [clock collection]
- ffi 2.1.3
- firebase_core_platform_interface 5.4.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.20.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_performance_platform_interface 0.1.5+2 [_flutterfire_internals firebase_core flutter plugin_platform_interface]
- firebase_performance_web 0.1.7+8 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- http_parser 4.1.2 [collection source_span string_scanner typed_data]
- http_profile 0.1.0
- leak_tracker 10.0.8 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.9 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 5.1.1
- matcher 0.12.17 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.16.0
- objective_c 4.1.0 [ffi flutter]
- path 1.9.1
- plugin_platform_interface 2.1.8 [meta]
- sky_engine 0.0.0
- source_span 1.10.1 [collection path term_glyph]
- stack_trace 1.12.1 [path]
- stream_channel 2.1.4 [async]
- string_scanner 1.4.1 [source_span]
- term_glyph 1.2.2
- test_api 0.7.4 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.4.0 [collection]
- vector_math 2.1.4
- vm_service 14.3.1
- web 1.1.0
- web_socket 0.1.6 [web]

Additional context and comments

When checked with dev tools, the status is null.

Image
@koji-1009 koji-1009 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Feb 14, 2025
@SelaseKay SelaseKay added plugin: performance platform: ios Issues / PRs which are specifically for iOS. labels Feb 14, 2025
@russellwheatley
Copy link
Member

Hey @koji-1009 - could you confirm that the response is different if firebase_performance is not a dependency in the project? i.e. perhaps another screenshot with the network tab showing successful response. Thanks 👍

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 14, 2025
@koji-1009
Copy link
Author

@russellwheatley
This is a screenshot of the case where firebase_performance is not added to depenency.

Image

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 14, 2025
@SelaseKay
Copy link
Contributor

Hi @koji-1009, I'm unable to reproduce this issue. Both seems to work fine for me.

@koji-1009
Copy link
Author

koji-1009 commented Feb 17, 2025

@SelaseKay
I've set the timeout and record it.

import 'package:cupertino_http/cupertino_http.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Demo', home: const MyHomePage());
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _httpResponse = '';
  String _cupertinoHttpResponse = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('HTTP Request Example')),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16),
        child: SizedBox(
          width: double.infinity,
          child: Column(
            children: [
              Text('http package'),
              ElevatedButton(
                onPressed: () async {
                  final client = Client();
                  try {
                    final response = await client
                        .get(Uri.parse('https://httpbin.org/get'))
                        .timeout(const Duration(seconds: 5));
                    setState(() {
                      _httpResponse = response.body;
                    });
                  } on Exception catch (e) {
                    setState(() {
                      _httpResponse = e.toString();
                    });
                  } finally {
                    client.close();
                  }
                },
                child: const Text('Make HTTP Request'),
              ),
              Text('http package response:'),
              Text(_httpResponse),
              const SizedBox(height: 16),
              Text('cupertino_http package'),
              ElevatedButton(
                onPressed: () async {
                  final client = CupertinoClient.defaultSessionConfiguration();
                  try {
                    final response = await client
                        .get(Uri.parse('https://httpbin.org/get'))
                        .timeout(const Duration(seconds: 5));
                    setState(() {
                      _cupertinoHttpResponse = response.body;
                    });
                  } on Exception catch (e) {
                    setState(() {
                      _cupertinoHttpResponse = e.toString();
                    });
                  } finally {
                    client.close();
                  }
                },
                child: const Text('Make HTTP Request'),
              ),
              Text('cupertino_http package response:'),
              Text(_cupertinoHttpResponse),
            ],
          ),
        ),
      ),
    );
  }
}
no_performance.mp4
add_performance.mp4

@koji-1009
Copy link
Author

@SelaseKay
Copy link
Contributor

Hi @koji-1009, I was able to reproduce the issue using your example app. However, I'm not sure if this can be resolved at the FlutterFire level.

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 19, 2025
@koji-1009
Copy link
Author

@SelaseKay
Excuse me. What should I respond to as a "customer response"? Do I need to submit the issue to another repository?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 19, 2025
@koji-1009
Copy link
Author

I added FirebasePerformance with SPM and CocoaPods to see how it works. In both cases, the HTTP GET by the cupertino_http package is successful.

https://github.com/koji-1009/pefromance_urlsession_example/tree/spm_performance
https://github.com/koji-1009/pefromance_urlsession_example/tree/pods_performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: performance type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants