Android crashes because Admob creates too many File Descriptors
See original GitHub issueProblem
I’m getting crashes from the Google Play Console because my game reaches the limit of max FileDescriptor object count:
"FORTIFY: FD_SET: file descriptor 1247 >= FD_SETSIZE 1024"
Upon investigating I found out that for each loaded ad Admob SDK creates about ~300-400 FileDescriptor objects. So while my game is idle it uses about 200-300, when I load an Interstitial and a Rewarded it reaches the max limit of 1024.
And one more issue: FileDescriptors are not released when the ad is loaded and then destroyed without showing it, which makes it possible to grow FileDescriptor count infinitely.
Note: Reaching the limit does not cause the game to crash immediately, but the game crashes when other SDKs interact with File Descriptors.
Environment
- Unity version: 2021.3.25f1
- Google Mobile Ads Unity plugin version: 8.4
- Platform: Android
- Platform OS version: 12+ (Any) https://i.imgur.com/ZK0US9W.png
- Specific Devices": Samsung A14 and many more https://i.imgur.com/o6QcjLU.png
- Mediation ad networks used, and their versions: None
Steps to reproduce:
- Download the official Hello World sample, and integrate the Admob SDK or Download this project
- Build in development mode and run on Android
- Connect the device and observe the File Descriptor usage using the ADB shell. You can use this Power Shell script
- Initially the usage will be around 200, after loading an Interstitial and a Rewarded it will grow significantly, and may reach the limit.
Demonstration video: https://youtu.be/xju_E4rvRG8
Relevant Code:
Sample Project Google Drive Link Power Shell script that I use to print File Descriptor usage Github Link An article that may be helpful Keeping File Descriptors (FD’s) in check on Android
Issue Analytics
- State:
- Created 2 months ago
- Reactions:1
- Comments:7 (3 by maintainers)
Same here
Plugin v8.4.1
Unity version 2022.3.5f1 Android 10 , 11
Application just closed before open any thing even unity splash screen