Commit graph

92 commits

Author SHA1 Message Date
Rashad Sookram
84db3b7d55
Log more info when select fails 2024-03-26 10:22:34 -04:00
Markus Handell
2a256c82ec Implement support for Chrome task origin tracing. #2/4
This prepares TaskQueueBase sub classes to be able to migrate to
the location and traits-based API. It re-introduces a Location class
into the webrtc namespace, which is meant to be overridden by Chromium.

Bug: chromium:1416199
Change-Id: I712c7806a71b3b99b2a2bf95e555b357c21c15ae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294381
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39400}
2023-02-27 13:17:38 +00:00
Danil Chapovalov
2ded55e0df Cleanup Thread::BlockingCall
Remove integration with socket server of the current thread
Network thread that uses PhysicalSocketServer shouldn't be allowed to do blocking calls
Other threads that use NullSocketServer do not need to process any messages while blocking

Bug: webrtc:14856
Change-Id: I56865b86e0992e60376ecefe163ff6b23911edca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291527
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39225}
2023-01-30 12:12:30 +00:00
Danil Chapovalov
c3c8934219 Use non recursive mutex in rtc::ThreadManager
ThreadManager, i.e. list of all thread is only used for debugging
purpose now, such uses do not enter the loop recursively

Bug: webrtc:11567
Change-Id: I7deb86e0245950c92fe27485285fd119baf6707a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/289461
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38986}
2023-01-03 13:28:50 +00:00
Markus Handell
82da9324bc Ensure task queues delete closures in task queue context.
Bug: webrtc:14449
Change-Id: I90d09d35398c1f8817701662f51cbc6a684a2fe0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275773
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38917}
2022-12-19 10:41:03 +00:00
Danil Chapovalov
3ab76d945c Use non-recursive mutex in rtc::Thread
With rtc::Thread::Clear removed, there are no longer calls to external code while holding the mutex and thus it doesn't need to be recursive.

Bug: webrtc:11567
Change-Id: If350684be0bfcbc33806019bd986138905aec66d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276542
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38179}
2022-09-23 11:59:57 +00:00
Danil Chapovalov
d44e3410b6 Delete rtc::Thread functions that use rtc::MessageHandler
Bug: webrtc:9702
Change-Id: I6fc8aa8a793caf19d62a149db1861c352c609255
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275774
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38150}
2022-09-21 11:33:47 +00:00
Danil Chapovalov
e16e3e2cb8 Delete MessageHandlerAutoCleanup and ThreadManager::Clear
Bug: webrtc:11988
Change-Id: Ic54d37fb802c9e55d417d65aa735fb07097d1b71
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275768
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38102}
2022-09-16 14:12:38 +00:00
Danil Chapovalov
ca1454a9c2 Delete rtc::Thread::Send in favor of rtc::Thread::BlockingCall
Bug: webrtc:9702
Change-Id: Ie425c99e8d05ad84801b527207732e4d45494dbd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275242
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38071}
2022-09-13 16:05:40 +00:00
Danil Chapovalov
7c323ad47c in rtc::Thread introduce Invoke without rtc::Location parameter
To reduce usage of rtc::MessageHandler, hide rtc::Thread::Send into private section with intention to deprecate it in favor of the new Invoke function.

Bug: webrtc:9702, webrtc:11318
Change-Id: Ib4c26f9abc361e05a45b2a91929af58ab160b3f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274166
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38036}
2022-09-08 15:00:40 +00:00
Markus Handell
9a21c49337 SocketServer: Migrate Wait/kForever to TimeDelta.
Bug: webrtc:13756
Change-Id: Ie36ca38b1ab336742231b101ef7bb5ccf3735659
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272102
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37903}
2022-08-25 13:01:34 +00:00
Danil Chapovalov
0bd166530d in rtc::Thread remove special handling of the Dispose message
rtc::Thread::Dispose is only used in test code,
but complicates the main thread loop.

Bug: webrtc:8324
Change-Id: I2dccdadcdc932b9992958d1e70fb93d1879b7618
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272821
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37894}
2022-08-24 18:58:17 +00:00
Danil Chapovalov
207f8536b2 In rtc::Thread hide MessageHandler handling as implementation details
Remote Peek function as unused
Move Get and Dispatch into private section to ensure they are not used
from outside.

Bug: webrtc:9702
Change-Id: Ibd0b236fe43543d60f97f988524526493bbeaaa7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272804
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37889}
2022-08-24 13:40:09 +00:00
Danil Chapovalov
7e8299b62e In rtc::Thread delete legacy implementation of the task queue
Bug: webrtc:14245
Change-Id: Ic0ad82f0eb2186367e794bbdc122de5b2f49204a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268902
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37600}
2022-07-22 19:48:22 +00:00
Danil Chapovalov
5286dcfab6 Migrate rtc_base and rtc_tools to absl::AnyInvocable based TaskQueueBase interface
Bug: webrtc:14245
Change-Id: I71abe3db7a23ad33bd175297e23fa8e927fa9628
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268768
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37553}
2022-07-19 10:57:42 +00:00
Danil Chapovalov
4bcf809df7 In rtc::Thread implement posting AnyInvocable
Lots of code call rtc::Thread directly instead of through TaskQueueBase
interface, thus to continue migration step by step rtc::Thread needs
to implement both old and new TaskQueueBase interfaces.

Bug: webrtc:14245
Change-Id: Ie7cac897a4c8a6227b8d467a39adb30aec6f1318
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267984
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37474}
2022-07-07 07:40:14 +00:00
Niels Möller
7a66900683 Delete rtc_base/atomic_ops.h
Bug: webrtc:9305
Change-Id: I3e8b0db03b84b5361d63db31ee23e6db3deabfe4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266497
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37348}
2022-06-28 08:32:13 +00:00
Artem Titov
c374d11fac Move to_queued_task.h and pending_task_safety_flag.h into public API
Bug: b/235812579
Change-Id: I9fa3dc4a65044df8b44fff4e9bfeac7233fa381c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266080
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37248}
2022-06-17 09:20:39 +00:00
Ali Tofigh
7fa9057a05 Adopt absl::string_view in function parameters under rtc_base/
This is part of a large-scale effort to increase adoption of
absl::string_view across the WebRTC code base.

This CL converts the majority of "const std::string&"s in function
parameters under rtc_base/ to absl::string_view.

Bug: webrtc:13579
Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Anders Lilienthal <andersc@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36239}
2022-03-17 15:39:26 +00:00
Mirko Bonadei
8382968781 Reland "Remove workaround in AutoSocketServerThread that isn't needed anymore."
This reverts commit e4d3952bf0.

Reason for revert: Speculative revert.

Original change's description:
> Revert "Remove workaround in AutoSocketServerThread that isn't needed anymore."
>
> This reverts commit 44156fa024.
>
> Reason for revert: Needed in order to revert https://webrtc-review.googlesource.com/c/src/+/249941, which introduced a crash
>
> Original change's description:
> > Remove workaround in AutoSocketServerThread that isn't needed anymore.
> >
> > Cleanup steps for the Connection class have changed as of:
> > https://webrtc-review.googlesource.com/c/src/+/249941
> >
> > However, it turns out that the PortTest suite still needs it, so the
> > workaround has migrated to there.
> >
> > Bug: none
> > Change-Id: Ia68f47b6c65b3a8fd5e8c04d70a43d15ba1a6422
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250223
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#35894}
>
> Bug: none
> Change-Id: I13a4a79ebcb864054d14c1ba7726e18e044e3bd4
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252542
> Auto-Submit: Taylor Brandstetter <deadbeef@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36076}

No-Try: True
Bug: none
Change-Id: If39bb2f26349c42c2377ed9f80c26eb18d90869f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252585
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36082}
2022-02-25 11:33:32 +00:00
Taylor Brandstetter
e4d3952bf0 Revert "Remove workaround in AutoSocketServerThread that isn't needed anymore."
This reverts commit 44156fa024.

Reason for revert: Needed in order to revert https://webrtc-review.googlesource.com/c/src/+/249941, which introduced a crash

Original change's description:
> Remove workaround in AutoSocketServerThread that isn't needed anymore.
>
> Cleanup steps for the Connection class have changed as of:
> https://webrtc-review.googlesource.com/c/src/+/249941
>
> However, it turns out that the PortTest suite still needs it, so the
> workaround has migrated to there.
>
> Bug: none
> Change-Id: Ia68f47b6c65b3a8fd5e8c04d70a43d15ba1a6422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250223
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35894}

Bug: none
Change-Id: I13a4a79ebcb864054d14c1ba7726e18e044e3bd4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252542
Auto-Submit: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36076}
2022-02-25 10:14:38 +00:00
Niels Möller
98d26df5b7 Reland "Delete NO_MAIN_THREAD_WRAPPING preprocessor define."
This is a reland of 0f78c6b28d

Original change's description:
> Delete NO_MAIN_THREAD_WRAPPING preprocessor define.
> 
> Since many tests rely on rtc::Thread::Current(), add an
> explicit rtc::AutoThread in the main() function used by tests.
> 
> Bug: webrtc:9714
> Change-Id: Id82121967c9621fe1c2945846009c48139fa57da
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/39680
> Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28000}

Bug: webrtc:9714
Change-Id: I85f8a7058387771a31c099b1080ae53f1648dce6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137513
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35932}
2022-02-07 12:47:06 +00:00
Tommi
44156fa024 Remove workaround in AutoSocketServerThread that isn't needed anymore.
Cleanup steps for the Connection class have changed as of:
https://webrtc-review.googlesource.com/c/src/+/249941

However, it turns out that the PortTest suite still needs it, so the
workaround has migrated to there.

Bug: none
Change-Id: Ia68f47b6c65b3a8fd5e8c04d70a43d15ba1a6422
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250223
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35894}
2022-02-03 07:29:22 +00:00
Henrik Boström
cf9899c518 TaskQueueBase: Add PostDelayedHighPrecisionTask().
As per go/postdelayedtask-precision-in-webrtc we want to reduce the
precision of PostDelayedTask() in order to schedule work on the CPU
more efficiently. In order not to break "high precision" use cases, a
new API is added to allow opting in to high precision.

PostDelayedHighPrecisionTask() has the same precision that
PostDelayedTask() has today, but by changing the interface's
requirements on PostDelayedTask(), adding the high precision version
of it will unblock making the old PostDelayedTask() API lower
precision.

This CL does not update implementations to support low precision so
until those are updated, both PostDelayedTask() and
PostDelayedHighPrecisionTask() have the same precision (=high).

This CL also adds TODOs to make some rtc::Thread-specific versions
of PostTask/PostDelayedTask obsolete, see
https://crbug.com/webrtc/13582 for more info.

Bug: webrtc:13583, webrtc:13582
Change-Id: I4c6d53d22bb299c49893ce9f3ef73a40d8c75de1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247367
Reviewed-by: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35748}
2022-01-20 10:45:10 +00:00
Byoungchan Lee
14af7622a7 Remove RTC_DISALLOW_COPY_AND_ASSIGN from rtc_base/
Bug: webrtc:13555, webrtc:13082
Change-Id: I406b7f04497562866ea3329e97c5adc96e927b6f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245680
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: (Daniel.L) Byoungchan Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/main@{#35691}
2022-01-13 20:42:15 +00:00
Artem Titov
d3251968d1 Prepare to rename RTC_NOTREACHED to RTC_DCHECK_NOTREACHED
Add implementation of RTC_DCHECK_NOTREACHED equal to the RTC_NOTREACHED.
The new macros will replace the old one when old one's usage will be
removed. The idea of the renaming to provide a clear signal that this
is debug build only macros and will be stripped in the production build.

Bug: webrtc:9065
Change-Id: I4c35d8b03e74a4b3fd1ae75dba2f9c05643101db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237802
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35348}
2021-11-15 21:44:59 +00:00
Mirko Bonadei
481e3451d1 Revert rtc_dcheck_always_on.
This CL reverts:
https://webrtc-review.googlesource.com/c/src/+/226864
https://webrtc-review.googlesource.com/c/src/+/226563

Reason for revert:
See also V8 equivalent: crrev.com/c/3055294.
This has been properly fixed by crrev.com/c/3053740.
Now dcheck_always_on already defaults to false for subprojects
like WebRTC and no other switch is required. The switch didn't fully
work anyways due to https://crbug.com/1231890.

No-Try: True
Bug: chromium:1225701, webrtc:12988
Change-Id: I9888d7ac02ef2ba4fdc372de20f1d2d71f6d0299
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227021
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34603}
2021-07-30 13:47:50 +00:00
Artem Titov
96e3b991da Use backticks not vertical bars to denote variables in comments for /rtc_base
Bug: webrtc:12338
Change-Id: I72fcb505a92f03b2ace7160ee33d555a977eddfd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226955
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34587}
2021-07-28 13:51:47 +00:00
Mirko Bonadei
179b46b5ae Add ScopedMessageData::Release.
This CL removes an unused ScopedMessageData ctor and introduces
ScopedMessageData::Release which is the first step in order to remove
the data() methods that return a reference to a std::unique_ptr (which
is an anti-pattern).

Bug: None
Change-Id: I8f3c3fcfebd127c07fe0b667ca3442a20f458f0c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226870
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34563}
2021-07-27 15:26:20 +00:00
Mirko Bonadei
8c185fcabe Reland "Add WebRTC specific dcheck_always_on."
This is a reland of 9f2a20f434

See https://webrtc-review.googlesource.com/c/src/+/226563/1..2
for the fix. RTC_DCHECK_ALWAYS_ON needs to be in public_configs
in order to be propagated together with header #includes and
avoid ODR violations.

Original change's description:
> Add WebRTC specific dcheck_always_on.
>
> Inspired by V8 CL: crrev.com/c/3038528.
>
> This makes the WebRTC's dcheck control independent of Chromium's and
> prepares switching Chromium's default behavior without affecting
> WebRTC developers or builders.
>
> Preparation for: https://crrev.com/c/2893204
>
> Bug: chromium:1225701, webrtc:12988
> Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Cr-Commit-Position: refs/heads/master@{#34512}

Bug: chromium:1225701, webrtc:12988
Change-Id: I1f78587487ee7b1a4a07b8c91b737a9e797b2323
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226563
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34519}
2021-07-21 13:26:14 +00:00
Mirko Bonadei
145f289552 Revert "Add WebRTC specific dcheck_always_on."
This reverts commit 9f2a20f434.

Reason for revert: see explanation on 
https://bugs.chromium.org/p/webrtc/issues/detail?id=12988#c4.

Original change's description:
> Add WebRTC specific dcheck_always_on.
>
> Inspired by V8 CL: crrev.com/c/3038528.
>
> This makes the WebRTC's dcheck control independent of Chromium's and
> prepares switching Chromium's default behavior without affecting
> WebRTC developers or builders.
>
> Preparation for: https://crrev.com/c/2893204
>
> Bug: chromium:1225701, webrtc:12988
> Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Cr-Commit-Position: refs/heads/master@{#34512}

TBR=mbonadei@webrtc.org,dpranke@google.com,orphis@webrtc.org,handellm@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I408ca6222e0d16e3d521708dfe5322236cf280d4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1225701, webrtc:12988
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226562
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34518}
2021-07-21 07:54:10 +00:00
Mirko Bonadei
9f2a20f434 Add WebRTC specific dcheck_always_on.
Inspired by V8 CL: crrev.com/c/3038528.

This makes the WebRTC's dcheck control independent of Chromium's and
prepares switching Chromium's default behavior without affecting
WebRTC developers or builders.

Preparation for: https://crrev.com/c/2893204

Bug: chromium:1225701, webrtc:12988
Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#34512}
2021-07-20 09:13:58 +00:00
Artem Titov
157371643d Enforce thread invoke policy for invokes to itself
Bug: None
Change-Id: Ic4a80973bd0901f69c66ecabd3c135566f4ef247
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219629
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34119}
2021-05-25 18:14:43 +00:00
Niels Möller
9bd2457857 Delete SignalQueueDestroyed
It was used only to break the circular dependency between SocketServer
and Thread at destruction time. Replaced with a method call to
SetMessageQueue(nullptr).

Bug: webrtc:11943
Change-Id: I0606d473ad79655cca28411bb02c21e21d2d7220
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215587
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33807}
2021-04-22 13:04:53 +00:00
Tomas Gunnarsson
89f3dd5bf7 Make RTC_LOG_THREAD_BLOCK_COUNT less spammy for known call counts
Also removing a count check from DestroyTransceiverChannel that's
not useful right now. We can bring it back when we have
DestroyChannelInterface better under control as far as Invokes goes.

Bug: none
Change-Id: I8e9c55a980f8f20e8b996fdc461fd90b0fbd4f3d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215201
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33730}
2021-04-14 12:19:12 +00:00
Tommi
fe041643b4 Add utility to count the number of blocking thread invokes.
This is useful to understand how often we block in certain parts of the
api and track improvements/regressions.

There are two macros, both are only active for RTC_DCHECK_IS_ON builds:

* RTC_LOG_THREAD_BLOCK_COUNT()
Example:
  void MyClass::MyFunction() {
    RTC_LOG_THREAD_BLOCK_COUNT();
    thread_->Invoke<void>([this](){ DoStuff(); });
  }

When executing this function during a test, the output could be:

  (my_file.cc:2): Blocking MyFunction: total=1 (actual=1, would=0)

The words 'actual' and 'would' reflect whether an actual thread switch
was made, or if in the case of a test using the same thread for more
than one role (e.g. signaling, worker, network are all the same thread)
that an actual thread switch did not occur but it would have occurred
in the case of having dedicated threads. The 'total' count is the sum.

* RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x)
Example:
  void MyClass::MyFunction() {
    RTC_LOG_THREAD_BLOCK_COUNT();
    thread_->Invoke<void>([this](){ DoStuff(); });
    thread_->Invoke<void>([this](){ MoreStuff(); });
    RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1);
  }

When a function is known to have blocking calls and we want to not
regress from the currently known number of blocking calls, we can use
this macro to state that at a certain point in a function, below
where RTC_LOG_THREAD_BLOCK_COUNT() is called, there must have occurred
no more than |x| (total) blocking calls. If more occur, a DCHECK will
hit and print out what the actual number of calls was:

# Fatal error in: my_file.cc, line 5
# last system error: 60
# Check failed: blocked_call_count_printer.GetTotalBlockedCallCount() <= 1 (2 vs. 1)

Bug: webrtc:12649
Change-Id: Ibac4f85f00b89680601dba54a651eac95a0f45d3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213782
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33632}
2021-04-07 10:02:41 +00:00
Artem Titov
d15a575ec3 Use SequenceChecker from public API
Bug: webrtc:12419
Change-Id: I00cca16a0ec70246156ba00b97aa7ae5ccbf5364
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/205323
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33220}
2021-02-10 15:04:55 +00:00
Harald Alvestrand
ba69442054 Configure threads with their own warning deadlines.
Design document:
https://docs.google.com/document/d/1c_Jk-eqoBl3mZcEW73OO_WOnWVO9nTU854DHcyqjQBo/edit?resourcekey=0-j2bRwX0nxCldQ_VjoPFAOQ#

Bug: webrtc:12405
Change-Id: Idab950a3293d7ca9328dfeb19ec6d3084f7e0e5f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203522
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33218}
2021-02-10 13:25:47 +00:00
Mirko Bonadei
e5f4c6b8d2 Reland "Refactor rtc_base build targets."
This is a reland of 69241a93fb

Fix: The problem was related to NO_MAIN_THREAD_WRAPPING, which
affects https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/rtc_base/thread.cc;l=257-263;drc=7acc2d9fe3a6e3c4d8881d2bdfc9b8968a724cd5.
The original CL didn't attach the definition of the macro
NO_MAIN_THREAD_WRAPPING when building for Chromium (which doesn't have
to be related to //rtc_base anymore but to //rtc_base:threading).

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

Bug: webrtc:9987
Change-Id: I7cdf49d2aac8357f1f50f90010bf2c2f62fa19f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202021
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33001}
2021-01-15 17:00:05 +00:00
Mirko Bonadei
7acc2d9fe3 Revert "Refactor rtc_base build targets."
This reverts commit 69241a93fb.

Reason for revert: Breaks WebRTC roll into Chromium.

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

TBR=mbonadei@webrtc.org,hta@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

No-Try: True
Bug: webrtc:9987
Change-Id: I1e36ad64cc60092f38d6886153a94f1a58339256
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201840
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32986}
2021-01-14 21:27:38 +00:00
Mirko Bonadei
69241a93fb Refactor rtc_base build targets.
The "//rtc_base:rtc_base" build target has historically been one of the
biggest targets in the WebRTC build. Big targets are the main source of
circular dependencies and non-API types leakage.

This CL is a step forward into splitting "//rtc_base:rtc_base" into
smaller targets (as originally started in 2018).

The only non-automated changes are (like re-wiring the build system):
* The creation of //rtc_base/async_resolver.{h,cc} which allows to
  break a circular dependency (is has been extracted from
  //rtc_base/net_helpers.{h,cc}).
* The creation of //rtc_base/internal/default_socket_server.{h,cc} to
  break another circular dependency.

Bug: webrtc:9987
Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32941}
2021-01-11 18:32:30 +00:00
Tomas Gunnarsson
77baeee99e Make MessageHandler be a pure virtual interface.
Bug: webrtc:11908
Change-Id: I35d3c4005d970082bff8c5ff24186aab54205c37
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185340
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32194}
2020-09-25 11:44:02 +00:00
Tomas Gunnarsson
abdb470d00 Make MessageHandler cleanup optional.
As documented in webrtc:11908 this cleanup is fairly invasive and
when a part of a frequently executed code path, can be quite costly
in terms of performance overhead. This is currently the case with
synchronous calls between threads (Thread) as well with our proxy
api classes.

With this CL, all code in WebRTC should now either be using MessageHandlerAutoCleanup
or calling MessageHandler(false) explicitly.

Next steps will be to update external code to either depend on the
AutoCleanup variant, or call MessageHandler(false).

Changing the proxy classes to use TaskQueue set of concepts instead of
MessageHandler. This avoids the perf overhead related to the cleanup
above as well as incompatibility with the thread policy checks in
Thread that some current external users of the proxies would otherwise
run into (if we were to use Thread::Send() for synchronous call).

Following this we'll move the cleanup step into the AutoCleanup class
and an RTC_DCHECK that all calls to the MessageHandler are setting
the flag to false, before eventually removing the flag and make
MessageHandler pure virtual.

Bug: webrtc:11908
Change-Id: Idf4ff9bcc8438cb8c583777e282005e0bc511c8f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183442
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32049}
2020-09-07 12:57:15 +00:00
Tomas Gunnarsson
0fd4c4e630 Stop using AutoThread in Thread::Send and make it test only.
Send() was creating an instance of AutoThread for every call,
which is equivalent of instantiatiating a whole new instance of
Thread (AutoThread inherits from Thread) and not just ensuring that
a thread instance is registered for the current thread, as the
comments indicated.

Bug: webrtc:11908
Change-Id: I8bbb43ca83c30d9f5e1928205b3611271ecad053
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183441
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32037}
2020-09-04 22:09:39 +00:00
Markus Handell
3cb525b378 Rename CriticalSection to RecursiveCriticalSection.
This name change communicates that the recursive critical section
should not be used for new code.
The relevant files are renamed rtc_base/critical_section* ->
rtc_base/deprecated/recursive_critical_section*

Bug: webrtc:11567
Change-Id: I73483a1c5e59c389407a981efbfc2cfe76ccdb43
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179483
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31754}
2020-07-17 09:19:50 +00:00
Artem Titov
dfc5f0d19d Reland "Add rtc::Thread invoke policy."
This is a reland of 26d4f9cd39

Original change's description:
> Add rtc::Thread invoke policy.
> 
> Policy will allow explicitly specify thread between which invokes are
> allowed, or explicitly forbid any invokes.
> 
> Change-Id: I360e7cba3ce1c21abd5047c6f175d8c4e0e99c6f
> Bug: webrtc:11728
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177526
> Reviewed-by: Tommi <tommi@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31604}

Bug: webrtc:11728
Change-Id: Id700b870d8c8dd6fa97380422e568dfb69de131f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178564
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31621}
2020-07-03 11:33:17 +00:00
Artem Titov
f37e9a385e Revert "Add rtc::Thread invoke policy."
This reverts commit 26d4f9cd39.

Reason for revert: Breaks downstream project

Original change's description:
> Add rtc::Thread invoke policy.
> 
> Policy will allow explicitly specify thread between which invokes are
> allowed, or explicitly forbid any invokes.
> 
> Change-Id: I360e7cba3ce1c21abd5047c6f175d8c4e0e99c6f
> Bug: webrtc:11728
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177526
> Reviewed-by: Tommi <tommi@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31604}

TBR=tommi@webrtc.org,titovartem@webrtc.org

Change-Id: If49596831d532ed97ac80416a2358c0fc4567758
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11728
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178561
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31611}
2020-07-02 10:17:13 +00:00
Artem Titov
26d4f9cd39 Add rtc::Thread invoke policy.
Policy will allow explicitly specify thread between which invokes are
allowed, or explicitly forbid any invokes.

Change-Id: I360e7cba3ce1c21abd5047c6f175d8c4e0e99c6f
Bug: webrtc:11728
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177526
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31604}
2020-07-01 12:01:32 +00:00
Jianjun Zhu
c33eeab2ca Fix an incorrect use of iterator.
This change uses index instead of iterator to access elements in
`all_targets` to avoid using invalidated iterator after insertion.

MSVC 2019 reports "cannot increment value-initialized deque iterator".
And C++ standard says "an insertion at either end of the deque
invalidates all the iterators to the deque".

Bug: webrtc:11255
Change-Id: I2167bfe875bb0059e81eba334bbd6921e287d6d9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176101
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31354}
2020-05-26 11:51:17 +00:00
Tommi
6866dc7806 Reland "Make sure that "current" rtc::Thread instances are always current for TaskQueueBase."
This reverts commit 28685dc08c.

Reason for revert: Speculative reland after looking into downstream
failures. It's possible that carryover state from unrelated tests
running in parallel was causing failures.

Original change's description:
> Revert "Make sure that "current" rtc::Thread instances are always current for TaskQueueBase."
> 
> This reverts commit 46b3bc6c24.
> 
> Reason for revert: Speculative revert. Breaks downstream project
> 
> Original change's description:
> > Make sure that "current" rtc::Thread instances are always current for TaskQueueBase.
> > 
> > This is a necessary part of fulfilling the TaskQueueBase
> > interface. If a thread does not register as the current TQ, yet offers
> > the TQ interface, TQ 'current' checks will not work as expected and
> > code that relies them (TaskQueueBase::Current() and IsCurrent())
> > will run in unexpected ways.
> > 
> > Bug: webrtc:11572
> > Change-Id: Iab747bc474e74e6ce4f9e914cfd5b0578b19d19c
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175080
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#31254}
> 
> TBR=mbonadei@webrtc.org,tommi@webrtc.org
> 
> Change-Id: I69ff3355f0ec447b25604bd95fdacbdb4d4f3f27
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:11572
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175104
> Reviewed-by: Artem Titov <titovartem@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31259}

TBR=mbonadei@webrtc.org,tommi@webrtc.org,titovartem@webrtc.org

# Not skipping CQ checks because this is a reland.

Bug: webrtc:11572
Change-Id: I00c82d99af8e05851769e09cb682b5b73895a6f3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175133
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31273}
2020-05-15 10:20:03 +00:00