Skip to content

[cronet_http] Potential problem when having multiple Flutter engines #1720

Closed

Description

@HosseinYousefi

There is an issue with the context getter of package:jni that it will crash if used again after creating a second engine: dart-lang/native#1865

This is because the second engine sets it to another context invalid for the first one. Can we check if cronet_http is susceptible to this problem? (or maybe we store the context and it won't cause a crash/cronet doesn't really need the context so it doesn't cause a crash/etc.)

If yes, then we would want to add a warning to cronet_http's readme about the fact that it's not safe to use it when using multiple flutter engines.

The problem can be solved either if we find a different way of getting the global context, which might work well at least for cronet. Or by exposing an "engine ID", so we can keep a map of contexts per Flutter engine instead of a singleton: flutter/flutter#163430

Activity

  1. knopp commented on Feb 19, 2025

    @knopp

    I think ok_http is going to have same issue? This should be solvable once we have engineId that we can match between plugin initialization and ffi call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package:cronet_httptype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions