[Google Pixel 3 XL Guides, News, & Discussion] rczrider:
Update #1: Items below marked through were removed since they don't really apply to Android 10.

Update #2: Edited to reflect changes in root with Android 11.

A quick note: everything below is assuming you're using Windows 10. When it says "Type...", this assumes you've opened a command window in the location of adb/fastboot and that all files referenced are in the same directory and (in some cases) renamed as I reference them (short names without spaces simplifies things). If you're using Powershell, you will probably need to change "adb" and "fastboot" to read ".\adb" and ".\fastboot" so Powershell will use the local files.

Unlocking the bootloader

THIS WILL WIPE YOUR PHONE, SO MAKE SURE EVERYTHING IS BACKED UP!

In Developer Options, enable OEM unlocking and confirm (it may ask you to input fingerprint or PIN/pattern/password)

Boot into Fastboot mode (see above)

Type to unlock:

fastboot flashing unlock

Use VOL+ key to get the options on the screen to read "Unlock the bootloader" and use PWR button to select

Type to reboot:

fastboot reboot

Locking the bootloader

THIS WILL WIPE YOUR PHONE, SO MAKE SURE EVERYTHING IS BACKED UP!

Boot into Fastboot mode (see above)

IMPORTANT: restore stock recovery if you replaced it with TWRP (this should prevent the "Can't find valid operating system" issue)

Type to lock:

fastboot flashing lock

Use VOL buttons to find "Lock the bootloader" and use PWR to select

Type to reboot:

fastboot reboot

Factory reset via fastboot (can also do this without wiping data)

THIS COULD WIPE YOUR PHONE, SO MAKE SURE EVERYTHING IS BACKED UP!

Download factory image ZIP and unzip all files into their own folder

Unlock bootloader (see above)

Reboot into Fastboot mode

You have 2 options:

Register the location of fastboot.exe with the PATH system variable and run "flash-all.bat"

Wipe data: just run "flash-all.bat" and call it a day

Do not wipe data: open "flash-all.bat" in a text editor (careful not to double-click and run it!), remove the "-w" from the last line to disable the wiping of data, then save, close, and run

Move the 3 files (bootloader IMG, radio IMG, image ZIP) into the ADB folder, rename for simplicity if you want, launch cmd or Powershell, and run the commands below (which come from "flash-all.bat")

Wipe data: type out commands below, but at last line, add "-w" flag: fastboot -w update image.zip

Do not wipe data: type out commands below as written (no "-w" flag)

The commands:

fastboot flash bootloader bootloader-blueline-XXXX.img
fastboot reboot bootloader
[wait for reboot]
fastboot flash radio radio-blueline-XXXX.img
fastboot reboot bootloader
[wait for reboot]
fastboot update image-blueline-XXXX.zip

Note: The last command (update image) will launch the red "fastbootd" screen, so don't worry and be patient while the command line tells you what's happening. The phone will reboot on its own into the Android system (not fastboot) afterward.

Root Android 10+ using Magisk (Canary channel)

This must be done after every update, and you cannot use the patched file from a different phone!

Unlock bootloader (see above)

Download factory image (not OTA, see link above)

Download and install Magisk Manager Canary (see link above)

In Magisk Manager settings, set Update Channel to "Canary"

Extract boot.img from image-blueline-XXXX.zip found in the factory image you downloaded

Place boot.img on your phone's internal storage

Open Magisk Manager and do:

tap "Install" button (next to "Magisk" in first block on the main screen)

"Select and Patch a File" option

Find boot.img file you just placed on your phone

tap "Let's Go"

When finished, move the newly-created magisk_patched.img file over to your computer's ADB directory

Reboot into bootloader

Type:

fastboot flash boot magisk_patched.img
fastboot reboot

Open up Magisk Manager and make sure everything's good!

Note : if you get stuck in fastboot mode or in a boot loop, flash the stock boot.img to both slots and try again

fastboot flash boot boot.img --slot all

Optional:

for adblocking, tap "Systemless hosts" in Magisk Manager, then install AdAway using F-Droid

install a performance kernel like Kirisakura for Bluecross (R)

Updating Android 10+ while rooted

You can't take an OTA while rooted, so updating Android 10+ (as in monthly updates) can be one of two ways.

Method #1 (faster, but more chance for issues)

Download OTA ZIP and move it to ADB folder (don't unzip it)

This does not require an unlocked bootloader, but does require USB debugging (see above)

Get boot.img from the factory image (see first post on where to download this) and place your ADB directory

Reboot into bootloader / fastboot and type to restore stock boot to both slots:

fastboot flash boot --slot all boot.img
fastboot reboot bootloader
[wait for reboot]

Use VOL buttons to select "Apply update from ADB"

Type (where filename is the name of the file you want to sideload):

adb sideload filename.zip

Wait for it to finish, will take you back to Recovery when it's done

Reboot using menu

Method #2 (takes longer, but best bet for minimal issues)

Follow "Factory reset via fastboot" instructions (see above, make sure you don't wipe your data!)

Take the OTA in the official way (through Android)

Follow "Root Android 10+ using Magisk Canary" instructions (see above)

Boot into TWRP (3.3.0-0 or higher)

Download TWRP IMG and place in ADB folder (rename the file to twrp.img)

If not already done, unlock the bootloader (see above)

Reboot into bootloader

Type to boot TWRP (it will restart and should boot into TWRP):

fastboot boot twrp.img

OPTIONAL: Replace recovery by installing TWRP

Your phone should automatically mount, so move twrp.img from PC to Download folder on phone's internal storage

Advanced > Install Recovery Ramdisk > choose TWRP IMG > Swipe to install

Back > Fix Recovery Bootloop > Reboot System > Do Not Install when asked if TWRP should install app

Root using Magisk (18.1 or higher)

Download Magisk ZIP and move to device

Boot into TWRP (see above)

Enter your PIN/pattern/password to decrypt (unnecessary if you are not using security on your phone)

Swipe to Allow Modifications (to system)

Install > find and select the Magisk ZIP > Slide to install

Wipe cache > Reboot system > Do Not Install when asked if TWRP should install app

Open Magisk Manager to verify latest and to install modules

"Can't find valid operating system" booting issue

Unlock your bootloader again (see above)

Follow steps for "Factory reset via fastboot" (see above) and keep the wipe flag

After it reboots, power off (press PWR and select "Power off" from menu)

Follow steps for "Locking the bootloader" (see above)

After it reboots into Fastboot mode, have it start using the PWR button

Android Recovery / "Cannot load Android system" booting issue

This can happen for a number of reasons, but the fix is the same: "Factory reset via fastboot" (see above). You probably do not need to wipe user data, so you can omit the "-w" flag.

If you still get the error message, select the "Try again" option. If it still doesn't work, try "Factory reset via fastboot" again, as well as "Try again". If it doesn't work this time, you probably have no choice but to do a factory reset (in which you will definitely lose your data).

If it happens after flashing Magisk in TWRP, though, you've got a slightly different issue and the problem will persist no matter how many times you flash the factory images and re-install Magisk. This is probably due to something leftover in the previous Magisk installation that conflicts with the new installation. There are two ways to handle this.

First and easiest: uninstall Magisk Manager app before rebooting into the bootloader and running fastboot commands. Then proceed as usual (sideload OTA or flash factory images via fastboot, boot TWRP, and flash Magisk). All guides for this are above. This method preserves any modules you have installed.

Second and more complete (if the above method still gives you trouble):

download to your phone the Magisk ZIP, Magisk Uninstaller ZIP, and Magisk APK from this XDA thread

uninstall the Magisk Manager app

reboot to bootloader

using fastboot, boot into TWRP using IMG (you don't need to replace boot with TWRP)

flash Magisk Uninstaller ZIP

wipe Dalvik

flash Magisk ZIP

wipe Dalvik

reboot system (do not install TWRP)

install Magisk Manager APK and re-install any modules