Skip to content

Too many open files causes crashes on iOS devices #2039

@PachecoLpG

Description

@PachecoLpG

What is the bug?

When zooming in/out on the map the following errors occur:

dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)

17 dnssd_clientstub ConnectToServer: socket failed 24 Too many open files

dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)

flutter: ClientException with SocketException: Failed host lookup: 'tile.openstreetmap.org' (OS Error: nodename nor servname provided, or >not known, errno = 8), uri=https://tile.openstreetmap.org/13/4362/2755.png

flutter: ClientException with SocketException: Connection failed (OS Error: Too many open files, errno = 24), address = >tile.openstreetmap.org, port = 443, uri=https://tile.openstreetmap.org/13/4361/2758.png

flutter: ClientException with SocketException: Failed host lookup: 'tile.openstreetmap.org' (OS Error: nodename nor servname provided, or >not known, errno = 8), uri=https://tile.openstreetmap.org/13/4360/2755.png

flutter: ClientException with SocketException: Failed host lookup: 'tile.openstreetmap.org' (OS Error: nodename nor servname provided, or >not known, errno = 8), uri=https://tile.openstreetmap.org/13/4360/2756.png

flutter: ClientException with SocketException: Failed host lookup: 'tile.openstreetmap.org' (OS Error: nodename nor servname provided, or >not known, errno = 8), uri=https://tile.openstreetmap.org/13/4361/2754.png

flutter: ClientException with SocketException: Failed host lookup: 'tile.openstreetmap.org' (OS Error: nodename nor servname provided, or >not known, errno = 8), uri=https://tile.openstreetmap.org/13/4361/2757.png

Some important points:

  • It does not occur frequently, it is random.
  • Only occurs on iOS devices
  • Can crash iOS devices on release mode

How can we reproduce it?

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(),
        home: FlutterMap(
          options: MapOptions(
            initialCenter:
                LatLng(51.509364, -0.128928), // Center the map over London
            initialZoom: 9.2,
          ),
          children: [
            TileLayer(
              // Bring your own tiles
              urlTemplate:
                  'https://tile.openstreetmap.org/{z}/{x}/{y}.png', // For demonstration only
              userAgentPackageName:
                  'com.example.app', // Add your app identifier
              // And many more recommended properties!
            ),
            RichAttributionWidget(
              // Include a stylish prebuilt attribution widget that meets all requirments
              attributions: [
                TextSourceAttribution('OpenStreetMap contributors'),
                // Also add images...
              ],
            ),
          ],
        ));
  }
}

flutter doctor -v :

[✓] Flutter (Channel stable, 3.27.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-BR)
    • Flutter version 3.27.2 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (5 weeks ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
 
[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
 
[✓] VS Code (version 1.97.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.104.0

[✓] Network resources
    • All expected network resources are available.

Do you have a potential solution?

I still don't know how to solve it, it could be something with the zoom speed generating a lot of tile requests, but I still have to do more tests, does anyone have any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis bug isn't reproducible, or the feature already exists

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions