There are many causes, but it would be helpful to know the year and make (manufacturer) of your truck. Vehicles have a lot of sensors and modules that control how the vehicle operates. If any of these components fails, it can cause performance issues such as lack of power or acceleration, stalling, hesitation on acceleration, rough idle and stumbling.
In addition to component failure, there may be an issue with the fuel system, ignition system or emissions system. The engine computer monitors how well the engine is running and has stored a trouble code when a problem is detected. A mechanic will be able to use a scanner tool to access the trouble codes and diagnose the problem.