There are several reasons your battery might be dying even while it's charging:
1. **Faulty Charger or Cable**: If your charger or cable is damaged or not compatible, it may not be delivering enough power.
2. **Battery Health**: Over time, batteries degrade and lose their ability to hold a charge. If your battery is old or worn out, it might not be able to keep up with your device's power needs.
3. **Background Processes**: Apps running in the background can consume a lot of power. If there are too many active processes, your device might be using more energy than the charger can provide.
4. **High Power Usage**: Intensive tasks, like gaming or video streaming, can draw more power than usual, leading to a drain even while charging.
5. **Software Issues**: Sometimes, software bugs or glitches can cause power management issues. An update or a reset might help.
6. **Environmental Factors**: Extreme temperatures can affect battery performance. If it’s too hot or too cold, the battery might not charge effectively.
If the problem persists, it might be worth checking with a professional or considering a battery replacement.