Skip to content

Fix Envoy Mobile bug where writing prevents the read loop from running,#2221

Merged
goaway merged 9 commits intoenvoyproxy:mainfrom
RyanTheOptimist:AsyncOnSendWindowAvailable
May 10, 2022
Merged

Fix Envoy Mobile bug where writing prevents the read loop from running,#2221
goaway merged 9 commits intoenvoyproxy:mainfrom
RyanTheOptimist:AsyncOnSendWindowAvailable

Conversation

@RyanTheOptimist
Copy link
Contributor

Fix Envoy Mobile bug where writing prevents the read loop from running,
by scheduling repeated onSendWindowAvailable calls in the next
dispatcher iteration.

Adds the regression test Charles cooked up in #2212

Fixes #2213

Risk Level: Low
Testing: New regression test
Docs Changes: N/A
Release Notes: N/A

by scheduling repeated onSendWindowAvailable calls in the next
dispatcher iteration.

Adds the regression test Charles cooked up in envoyproxy#2212

Fixes envoyproxy#2213

Signed-off-by: Ryan Hamilton <rch@google.com>
@RyanTheOptimist RyanTheOptimist force-pushed the AsyncOnSendWindowAvailable branch from 9902a88 to a943abc Compare April 27, 2022 22:39
@RyanTheOptimist
Copy link
Contributor Author

@alyssawilk please take a look. I'm not entirely sure if this is the right approach.

Signed-off-by: Ryan Hamilton <rch@google.com>
Signed-off-by: Ryan Hamilton <rch@google.com>
@RyanTheOptimist
Copy link
Contributor Author

FYI: This PR is not complete; I'm looking for guidance if this approach seems reasonable.

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think this is the right away to go about it, thanks for tackling it! I'd be inclined to unit test as well as you get it ready.

if (direct_stream->read_disable_count_ == 0) {
// If there is still buffer space after the write, notify the sender
// that send window is available.
// that send window is available, on the next dispatcher iteration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it's worth commenting why the delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done.

// that send window is available, on the next dispatcher iteration.
direct_stream->wants_write_notification_ = false;
direct_stream->callbacks_->onSendWindowAvailable();
scheduled_callback_ = dispatcher_.createSchedulableCallback(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't remember offhand: do we need to create a new one each time, or only the one time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice. That seems to work. Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently it didn't work - can we call out why we always need to create in a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done.

Signed-off-by: Ryan Hamilton <rch@google.com>
Signed-off-by: Ryan Hamilton <rch@google.com>
Signed-off-by: Ryan Hamilton <rch@google.com>
alyssawilk
alyssawilk previously approved these changes Apr 28, 2022
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LBTM :-)

Copy link
Contributor Author

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test coverage added via the changes to the existing tests.

if (direct_stream->read_disable_count_ == 0) {
// If there is still buffer space after the write, notify the sender
// that send window is available.
// that send window is available, on the next dispatcher iteration.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done.

// that send window is available, on the next dispatcher iteration.
direct_stream->wants_write_notification_ = false;
direct_stream->callbacks_->onSendWindowAvailable();
scheduled_callback_ = dispatcher_.createSchedulableCallback(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice. That seems to work. Done!

@RyanTheOptimist
Copy link
Contributor Author

@danzh2010 FYI

@RyanTheOptimist
Copy link
Contributor Author

@jpsim Would you mind taking a look at this? Or redirect if someone else would be a better choice?

@RyanTheOptimist
Copy link
Contributor Author

@goaway as per our discussion in the community meeting, what do you think of this change?

goaway
goaway previously approved these changes May 5, 2022
Copy link
Contributor

@goaway goaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our discussion this past week, and given the fact that this is all effectively guarded by the explicit flow control flag (which is off by default), I think it's reasonable to move forward with this.

Thanks for the discussion and investigation @RyanTheOptimist and @carloseltuerto.

@goaway
Copy link
Contributor

goaway commented May 5, 2022

Rerunning the failed CI job.

@RyanTheOptimist RyanTheOptimist dismissed stale reviews from goaway and alyssawilk via ad82119 May 6, 2022 19:14
Signed-off-by: Ryan Hamilton <rch@google.com>
@RyanTheOptimist RyanTheOptimist force-pushed the AsyncOnSendWindowAvailable branch from ad82119 to 648522a Compare May 7, 2022 14:45
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, I want to prematurely optimize that callback creation so badly :-P

@goaway
Copy link
Contributor

goaway commented May 10, 2022

Thanks, @RyanTheOptimist!

@goaway goaway merged commit 643831b into envoyproxy:main May 10, 2022
@carloseltuerto
Copy link
Contributor

When removing this line,

@Ignore("https://github.com/envoyproxy/envoy-mobile/issues/2213")

This unfortunately, this ends up with crash more than 50% of the time:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000105cb1b00, pid=77193, tid=32123
#
# JRE version: OpenJDK Runtime Environment Zulu11.50+19-CA (11.0.12+7) (build 11.0.12+7-LTS)
# Java VM: OpenJDK 64-Bit Server VM Zulu11.50+19-CA (11.0.12+7-LTS, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# May 10, 2022 7:06:33 PM io.netty.handler.logging.LoggingHandler channelInactive
INFO: [id: 0xc19fa4fa, L:/0:0:0:0:0:0:0:0:61521] INACTIVE
May 10, 2022 7:06:33 PM io.netty.handler.logging.LoggingHandler channelUnregistered
INFO: [id: 0xc19fa4fa, L:/0:0:0:0:0:0:0:0:61521] UNREGISTERED
V  [libjvm.dylib+0x379b00]  jni_GetObjectClass+0x120
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

jpsim added a commit that referenced this pull request May 10, 2022
* main:
  build: remove dist/ (#2184)
  Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221)
  Add comments to CronetBidirectionalStream (#2266)
  CronetBidirectionalStream  (#2164)
  ci: update build image (#2261)
  Bump Lyft Support Rotation (#2260)

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim added a commit that referenced this pull request May 10, 2022
* main:
  build: remove dist/ (#2184)
  Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221)
  Add comments to CronetBidirectionalStream (#2266)
  CronetBidirectionalStream  (#2164)
  ci: update build image (#2261)
  Bump Lyft Support Rotation (#2260)

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim added a commit that referenced this pull request May 12, 2022
* main:
  Add assert when failing to get_env (#2253)
  Update Kotlin standard libraries to 1.6.21 (#2256)
  iOS: Change release artifacts to use xcframeworks (#2217)
  build: remove dist/ (#2184)
  Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221)
  Add comments to CronetBidirectionalStream (#2266)
  CronetBidirectionalStream  (#2164)

Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onResponseHeaders not called on continuous sendData

5 participants