Skip to content

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

Closed
@koji-1009

Description

@koji-1009

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: iosIssues / PRs which are specifically for iOS.plugin: performancetype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions