Skip to content

Conversation

@peaBerberian
Copy link
Collaborator

The __RX_PLAYER_DEBUG_MODE__ boolean

The RxPlayer has a hidden feature where if an __RX_PLAYER_DEBUG_MODE__ boolean is declared globally and set to true before the RxPlayer's code is imported, it will output debug logs.

This was initially added as a mean to facilitate debugging, especially while relying on our RxPaired inspector.

Though we now end up communicating that trick to more people to facilitate quick checks:

  • applications relying on the RxPlayer which seem to have a fairly simple issue can set this to very quickly communicate us logs without having to understand our debug tools nor perform re-builds on their side.

  • in some scenarios, we even had users (though still in a professional context) wanting us to check why the player behaved the way it did on their devices.

    As those were technical people, we had no issue just telling them to set a boolean in the console and communicate to us the outputted logs.

Problems with it

Logs are then generally just copy-pasted from e.g. Chrome's inspector, and as such have a lot of noise we don't need (call stack info, object structure from their own code, CORS from their applications etc.), no timestamp, and no clear boundary between logs vs line breaks inside a single log.

Thus, it's less convenient to us than relying on RxPaired or than re-building with both LogLevel = "DEBUG" AND LogFormat = "full".

Proposal

So I here propose that RX_PLAYER_DEBUG_MODE__ also set LogFormat to "full".

This will add timestamps + a namespace to all new logs produced by the RxPlayer, then facilitating our exploitation and opening the way for easier import into RxPaired's post-debugger mode.

Though to keep in mind that this will then always lead to RxPaired's "double formatting" problem as exposed in canalplus/RxPaired#22.

As such canalplus/RxPaired#22 or a similar work-around is a requirement before merging this.

Note that there are other solutions to fix this, like creating two global booleans, e.g. one used by RxPaired and one for users, but here I ended up preferring the ugly double formatting work-around as a lesser evil.

peaBerberian added a commit to canalplus/RxPaired that referenced this pull request Jan 9, 2025
This is an alternative attempt (after
#22) at fixing the
"double formatting" situation brought by
canalplus/rx-player#1469 that may be made much
more frequent by canalplus/rx-player#1625.

This solution fixes it client-side instead, which could be seen as
arguably less ugly.

The idea is to rely on the fact that the RxPlayer does full formatting
by calling log functions with at least three arguments:
  1. The timestamp in a string format with always numbers after a comma
  2. A "namespace" (e.g. "[warn]")
  3-n. The log message's arguments

By considering this, we can very easily detect client-side a probable
case of full formatting.
peaBerberian added a commit to canalplus/RxPaired that referenced this pull request Jan 9, 2025
This is an alternative attempt (after
#22) at fixing the
"double formatting" situation brought by
canalplus/rx-player#1469 that may be made much
more frequent by canalplus/rx-player#1625.

This solution fixes it client-side instead, which could be seen as
arguably less ugly.

The idea is to rely on the fact that the RxPlayer does full formatting
by calling log functions with at least three arguments:
  1. The timestamp in a string format with always numbers after a comma
  2. A "namespace" (e.g. "[warn]")
  3-n. The log message's arguments

By considering this, we can very easily detect client-side a probable
case of full formatting.
The `__RX_PLAYER_DEBUG_MODE__` boolean
--------------------------------------

The RxPlayer has a hidden feature where if a global
`__RX_PLAYER_DEBUG_MODE__` boolean is declared globally and set to
`true` before its code its imported, it will output debug logs.

This was initially added as a mean to facilitate debugging, especially
while relying on our [RxPaired](https://github.com/canalplus/RxPaired)
inspector.

Though we now end up communicating that trick to more people to
facilitate quick checks:

  - applications relying on the RxPlayer which seem to have a fairly
    simple issue can set this to very quickly communicate us logs without
    having to understand our debug tools nor perform re-builds on their
    side.

  - in some scenarios, we even had users (though still in a professional
    context) wanting us to check why the player behaved the way it did
    on their devices.

    As those were technical people, we had no issue just telling them to
    set a boolean in the console and communicate to us the outputted logs.

Problems with it
----------------

Logs are then generally just copy-pasted from e.g. Chrome's inspector,
and as such have a lot of noise we don't need (call stack info, object
structure from their own code, CORS from their applications etc.), no
timestamp, and without a clear boundary between log lines vs line break
in a single log.

Thus, it's less convenient to us than relying on `RxPaired` or than
re-building with both `LogLevel = "DEBUG"` **AND** `LogFormat =
"full"`.

Proposal
--------

So I here propose that `RX_PLAYER_DEBUG_MODE__` also set `LogFormat` to
`"full"`.

This will add timestamps + a namespace to all new logs produced by the
RxPlayer, then facilitating our exploitation and opening the way for
easier import into RxPaired's post-debugger mode.

Though to keep in mind that this will then always lead to `RxPaired`'s
"double formatting" problem as exposed in canalplus/RxPaired#22.

As such canalplus/RxPaired#22 or a similar
work-around is a requirement before merging this.

_Note that there are other solutions to fix this, like creating two
global booleans, e.g. one used by RxPaired and one for users, but here I
ended up preferring the ugly double formatting work-around as a lesser
evil._
@peaBerberian peaBerberian force-pushed the misc/logformat-full-on-debug-mode branch from b3f6e16 to 8c720a0 Compare January 28, 2025 13:52
@github-actions
Copy link

Automated performance checks have been performed on commit 8c720a0f623c6acee76060942eb8aa364efaec94 with the base branch dev.

Tests results

✅ Tests have passed.

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 19.21ms -> 19.33ms (-0.118ms, z: 0.71434) 26.55ms -> 26.55ms
seeking 13.95ms -> 14.62ms (-0.662ms, z: 1.26285) 11.25ms -> 11.10ms
audio-track-reload 25.46ms -> 25.48ms (-0.011ms, z: 0.45009) 37.35ms -> 37.20ms
cold loading multithread 47.43ms -> 47.58ms (-0.159ms, z: 9.66480) 69.30ms -> 68.40ms
seeking multithread 15.89ms -> 23.93ms (-8.032ms, z: 1.12849) 10.35ms -> 10.35ms
audio-track-reload multithread 25.42ms -> 25.28ms (0.142ms, z: 2.74419) 37.50ms -> 37.20ms
hot loading multithread 14.96ms -> 14.74ms (0.220ms, z: 4.67307) 21.60ms -> 21.30ms

If you want to skip performance checks for latter commits, add the skip-performance-checks label to this Pull Request.

@peaBerberian peaBerberian added the Priority: 3 (Low) This issue or PR has a low priority. label Feb 26, 2025
peaBerberian added a commit to canalplus/RxPaired that referenced this pull request Mar 17, 2025
This is an alternative attempt (after
#22) at fixing the
"double formatting" situation brought by
canalplus/rx-player#1469 that may be made much
more frequent by canalplus/rx-player#1625.

This solution fixes it client-side instead, which could be seen as
arguably less ugly.

The idea is to rely on the fact that the RxPlayer does full formatting
by calling log functions with at least three arguments:
  1. The timestamp in a string format with always numbers after a comma
  2. A "namespace" (e.g. "[warn]")
  3-n. The log message's arguments

By considering this, we can very easily detect client-side a probable
case of full formatting.
@peaBerberian peaBerberian merged commit d6f299e into dev Mar 17, 2025
11 checks passed
@peaBerberian peaBerberian added this to the 4.3.0 milestone Mar 27, 2025
@peaBerberian peaBerberian mentioned this pull request Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 3 (Low) This issue or PR has a low priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants