http icon indicating copy to clipboard operation
http copied to clipboard

java.lang.NullPointerException: Parameter specified as non-null is null: method io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>,

Open escamoteur opened this issue 1 year ago • 12 comments

found in sentry:

JniException: Exception in Java code called through JNI: java.lang.NullPointerException: Parameter specified as non-null is null: method io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>, parameter callback

java.lang.NullPointerException: Parameter specified as non-null is null: method io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>, parameter callback
	at io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>(Unknown Source:2)
  File "accessors.dart", line 119, in JniAccessorWrappers.throwException
  File "accessors.dart", line 11, in _check
  File "accessors.dart", line 16, in JniResultMethods.check
  File "accessors.dart", line 54, in JniResultMethods.objectPointer
  File "accessors.dart", line 59, in JniResultMethods.reference
  File "jni_bindings.dart", line 491, in new UrlRequestCallbackProxy.new1
  File "cronet_client.dart", line 413, in CronetClient.send
  File "storage_service_impl.dart", line 199, in StorageServiceImplementation._uploadToS3
  File "storage_service_impl.dart", line 155, in StorageServiceImplementation.uploadImage
  File "upload_image.dart", line 19, in uploadImage
  File "async", in Future.wait.<fn>
  File "watch_composer_data.dart", line 563, in WatchComposerData.createPayload
  File "collections_manager_impl.dart", line 129, in new CollectionsManagerImplementation.<fn>
  File "flutter_command.dart", line 213, in Command.execute
  File "<asynchronous suspension>"
  File "composer_body.dart", line 225, in ComposerBodyState._onSubmit
  File "composer_body_template.dart", line 128, in _ComposerBodyTemplateState.build.<fn>.<fn>
  File "action_futurizer.dart", line 38, in _WcActionFuturizerState._onTap
  File "ink_well.dart", line 1253, in _InkResponseState.handleTap
  File "recognizer.dart", line 344, in GestureRecognizer.invokeCallback
  File "tap.dart", line 652, in TapGestureRecognizer.handleTapUp
  File "tap.dart", line 309, in BaseTapGestureRecognizer._checkUp
  File "tap.dart", line 279, in BaseTapGestureRecognizer.acceptGesture
  File "arena.dart", line 167, in GestureArenaManager.sweep
  File "binding.dart", line 499, in GestureBinding.handleEvent
  File "binding.dart", line 475, in GestureBinding.dispatchEvent
  File "binding.dart", line 425, in RendererBinding.dispatchEvent
  File "binding.dart", line 420, in GestureBinding._handlePointerEventImmediately
  File "binding.dart", line 383, in GestureBinding.handlePointerEvent
  File "binding.dart", line 330, in GestureBinding._flushPointerEventQueue
  File "binding.dart", line 299, in GestureBinding._handlePointerDataPacket

escamoteur avatar Jul 21 '24 15:07 escamoteur

cc @HosseinYousefi

escamoteur avatar Jul 22 '24 17:07 escamoteur

@escamoteur Which version of cronet_http are you using? (Or rather, has been used in the version that crashed on Sentry)

HosseinYousefi avatar Jul 23 '24 08:07 HosseinYousefi

Ahm soorry 1.3.1

escamoteur avatar Jul 23 '24 13:07 escamoteur

Ahm soorry 1.3.1

Try upgrading to 1.3.2 and let me know if any of your issues persists (including the issue opened in the Flutter repo).

HosseinYousefi avatar Jul 23 '24 14:07 HosseinYousefi

Ok, next Version will do Am 23. Juli 2024, 15:07 +0100 schrieb Hossein Yousefi @.***>:

Ahm soorry 1.3.1 Try upgrading to 1.3.2 and let me know if any of your issues persists (including the issue opened in the Flutter repo). — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

escamoteur avatar Jul 23 '24 14:07 escamoteur

I think that this fixed. Please reopen if it is not.

brianquinlan avatar Nov 07 '24 02:11 brianquinlan

I'm using v1.3.4 and still experimenting with this.

Exception in Java code called through JNI: java.lang.NullPointerException: Parameter specified as non-null is null: method io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>, parameter callback

java.lang.NullPointerException: Parameter specified as non-null is null: method io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>, parameter callback
	at io.flutter.plugins.cronet_http.UrlRequestCallbackProxy.<init>(Unknown Source:2)

AlexV525 avatar Jul 08 '25 09:07 AlexV525

This is odd. We're only once constructing the UrlRequestCallbackProxy and there we are not passing null to the parameter callback. I reopened the issue to investigate more – do you have a reproducible example?

HosseinYousefi avatar Jul 10 '25 08:07 HosseinYousefi

@HosseinYousefi I cannot share the endpoint in public since it involves credentials. However, I'm happy to share more information via private email and provide additional details.

We are using the embedded version of the Cronet (enabled by --dart-define=cronetNoPlay=true). We are also not using the http + cronet_http directly, but the native_dio_adapter that bridges the engine for requests.

https://github.com/dart-lang/http/blob/4209e846100cb22d60dea7e48727334b8c55be34/pkgs/cronet_http/android/build.gradle#L67

The failing request is a POST request, with a certain payload where every key and value are not null. Also, a bunch of header fields are added.

This request was only used by a single piece of code and runs at everytime when the app starts. Not only did the issue occur at this endpoint, but also:

Exception in Java code called through JNI: java.lang.NullPointerException: URL is required.

java.lang.NullPointerException: URL is required.
	at org.chromium.net.impl.UrlRequestBuilderImpl.<init>(Unknown Source:65)
	at org.chromium.net.impl.CronetEngineBase.newUrlRequestBuilder(SourceFile:2)
	at org.chromium.net.impl.CronetUrlRequestContext.newUrlRequestBuilder(Unknown Source:0)

We used to use the Dart original client, and the Cronet version was shipped to some of our colleagues recently. From what I've observed, we used to have receiveTimeout a few times. In dio, receiveTimeout indicates HttpClientRequest.close is not complete within the specified duration. So here I assume that the engine fails to parse parameters when the request has not been responded to.

I'm also the core maintainer of the package:dio and package:native_dio_adapter; from what I can tell, it doesn't seem to be a third-party (our) issue.

AlexV525 avatar Jul 11 '25 02:07 AlexV525

Coming back to this. Could you please confirm if you're still having this problem with the latest version of cronet_http (which upgrades jni/jnigen versions)?

HosseinYousefi avatar Jul 25 '25 12:07 HosseinYousefi

I don't think I can still repro this from my observation with our crashlytics, it seems resolved in the latest version.

AlexV525 avatar Aug 28 '25 21:08 AlexV525

I'll keep the issue open for a bit. Let me know if you still get this.

HosseinYousefi avatar Aug 29 '25 08:08 HosseinYousefi